Module: Braque::Relations
- Included in:
- Model::ClassMethods
- Defined in:
- lib/braque/relations.rb
Instance Method Summary collapse
- #belongs_to(relation) ⇒ Object
-
#has_many(relation) ⇒ Object
rubocop:disable Style/PredicateName.
Instance Method Details
#belongs_to(relation) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/braque/relations.rb', line 3 def belongs_to(relation) define_method relation do relation.to_s.classify.constantize.new( self.class.client.method(self.class.instance_method_name) .call() .method(relation).call ) end end |
#has_many(relation) ⇒ Object
rubocop:disable Style/PredicateName
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/braque/relations.rb', line 14 def has_many(relation) define_method relation do |params = {}| response = self.class.client.method(self.class.instance_method_name) .call() .method(relation).call(params) Braque::Collection::LinkedArray.new( response, relation.to_s.classify.singularize.constantize ) end end |