Last active
October 4, 2015 10:35
-
-
Save davejlong/f353ac585db96b63939d to your computer and use it in GitHub Desktop.
Representing relationships in Lotus::Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Conference | |
include Lotus::Entity | |
attributes :title, :call_code, :technician_id | |
# Are the following 2 methods correct for representing the relationship to Technician | |
def technician | |
@technician ||= TechnicianRepository.find @technician_id | |
end | |
def technician=(technician) | |
@technician = technician | |
@technician_id = technician.id | |
end | |
def call_code | |
@call_code ||= rand 1000...9999 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConferenceRepository | |
include Lotus::Repository | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collection :conferences do | |
entity Conference | |
repository ConferenceRepository | |
attribute :id, Integer | |
attribute :title, String | |
attribute :call_code, Integer | |
attribute :technician_id, Integer | |
end | |
collection :technicians do | |
entity Technician | |
repository TechnicianRepository | |
attribute :id, Integer | |
attribute :name, String | |
attribute :email, String | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Technician | |
include Lotus::Entity | |
attributes :name, :email | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TechnicianRepository | |
include Lotus::Repository | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment