Refactor db models

master
E. Almqvist 3 years ago
parent 2e3c992e23
commit 98e080bc2c
  1. 2
      src/app.rb
  2. 36
      src/db_models.rb

@ -119,7 +119,7 @@ post "/login" do
end
end
get "/logout" do
get "/logout" do # TODO: make me post
session.clear
redirect "/"
end

@ -2,15 +2,15 @@
class User < EntityModel
attr_reader :email, :name, :bio_text, :balance, :avatar_url, :pw_hash, :reputation
def initialize(user_info)
super user_info
@email = user_info["email"]
@name = user_info["name"]
@bio_text = user_info["bio_text"]
@balance = user_info["balance"]
@avatar_url = user_info["avatar_url"]
@reputation = user_info["reputation"]
@pw_hash = user_info["pw_hash"]
def initialize(data)
super data
@email = data["email"]
@name = data["name"]
@bio_text = data["bio_text"]
@balance = data["balance"]
@avatar_url = data["avatar_url"]
@reputation = data["reputation"]
@pw_hash = data["pw_hash"]
end
def avatar
@ -130,11 +130,11 @@ end
class Role < EntityModel
attr_reader :name, :color, :flags
def initialize(role_info)
super role_info
@name = role_info["name"]
@color = role_info["color"]
@flags = role_info["flags"]
def initialize(data)
super data
@name = data["name"]
@color = data["color"]
@flags = data["flags"]
end
def self.find_by_id(id)
@ -170,3 +170,11 @@ class User_Role_relation < EntityModel
end
end
end
class Auction < EntityModel
def initialize(data)
super data
@title = data["title"]
end
end

Loading…
Cancel
Save