Class: Her::Model::Associations::Association
- Inherits:
-
Object
- Object
- Her::Model::Associations::Association
- Defined in:
- lib/castle-her/model/associations/association.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#find(id) ⇒ Object
Fetches the data specified by id.
-
#where(params = {}) ⇒ Object
(also: #all)
Add query parameters to the HTTP request performed to fetch the data.
Instance Method Details
#find(id) ⇒ Object
Fetches the data specified by id
94 95 96 97 98 |
# File 'lib/castle-her/model/associations/association.rb', line 94 def find(id) return nil if id.blank? path = build_association_path lambda { "#{@parent.request_path(@params)}#{@opts[:path]}/#{id}" } @klass.get_resource(path, @params) end |
#where(params = {}) ⇒ Object Also known as: all
Add query parameters to the HTTP request performed to fetch the data
78 79 80 81 |
# File 'lib/castle-her/model/associations/association.rb', line 78 def where(params = {}) return self if params.blank? && @parent.attributes[@name].blank? AssociationProxy.new self.clone.tap { |a| a.params = a.params.merge(params) } end |