Module: RouteNGNClient::Model::ClassMethods
- Included in:
- RouteNGNClient::Model
- Defined in:
- lib/routengn_client/model.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#only_children ⇒ Object
Returns the value of attribute only_children.
-
#parents ⇒ Object
Returns the value of attribute parents.
Instance Method Summary collapse
- #belongs_to(*args) ⇒ Object
- #from_hash(h) ⇒ Object
- #from_json(s) ⇒ Object
- #has_many(*args) ⇒ Object
- #has_one(*args) ⇒ Object
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
30 31 32 |
# File 'lib/routengn_client/model.rb', line 30 def children @children end |
#only_children ⇒ Object
Returns the value of attribute only_children.
31 32 33 |
# File 'lib/routengn_client/model.rb', line 31 def only_children @only_children end |
#parents ⇒ Object
Returns the value of attribute parents.
29 30 31 |
# File 'lib/routengn_client/model.rb', line 29 def parents @parents end |
Instance Method Details
#belongs_to(*args) ⇒ Object
41 42 43 44 45 |
# File 'lib/routengn_client/model.rb', line 41 def belongs_to(*args) @parents = args.collect do |arg| "RouteNGNClient::#{arg.to_s.classify}".constantize end end |
#from_hash(h) ⇒ Object
33 34 35 |
# File 'lib/routengn_client/model.rb', line 33 def from_hash(h) new h end |
#from_json(s) ⇒ Object
37 38 39 |
# File 'lib/routengn_client/model.rb', line 37 def from_json(s) from_hash MultiJson.load(s, :symbolize_keys => true) end |
#has_many(*args) ⇒ Object
47 48 49 50 51 |
# File 'lib/routengn_client/model.rb', line 47 def has_many(*args) @children = args.collect do |arg| "RouteNGNClient::#{arg.to_s.classify}".constantize end end |
#has_one(*args) ⇒ Object
53 54 55 56 57 |
# File 'lib/routengn_client/model.rb', line 53 def has_one(*args) @only_children = args.collect do |arg| "RouteNGNClient::#{arg.to_s.classify}".constantize end end |