Module: Arke::Resource::Associations::ClassMethods
- Defined in:
- lib/arke/resource/associations.rb
Instance Method Summary collapse
Instance Method Details
#belongs_to(name, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/arke/resource/associations.rb', line 21 def belongs_to(name, ={}) # self.associations ||= {} # self.associations[name] = {class: infer_class(name, options), options: options} # define_method name do # if self.persisted? # instance_variable_set "@#{name}".to_sym, self.class.associations[name][:class]. # new(id: self.send("#{name}_id".to_sym)).reload unless instance_variable_get("@#{name}".to_sym) # instance_variable_get("@#{name}".to_sym) # else # nil # end # end end |
#has_many(name, options = {}) ⇒ Object
35 36 37 |
# File 'lib/arke/resource/associations.rb', line 35 def has_many(name, ={}) build_association(:has_many, name, '/{parent_resource_name}/{relation_id}/{resource_name}?{query*}', self._collection, ) end |