Module: Protip::Resource::Associations::Association
- Included in:
- BelongsToAssociation, BelongsToPolymorphicAssociation
- Defined in:
- lib/protip/resource/associations/association.rb
Instance Method Summary collapse
- #association_name ⇒ Object
- #define_accessors! ⇒ Object
- #read(resource) ⇒ Object
-
#resource_class ⇒ Object
Individual reference classes must implement.
- #write(resource, value) ⇒ Object
Instance Method Details
#association_name ⇒ Object
25 26 27 |
# File 'lib/protip/resource/associations/association.rb', line 25 def association_name raise NotImplementedError end |
#define_accessors! ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/protip/resource/associations/association.rb', line 8 def define_accessors! resource_class.class_exec(self, association_name) do |association, association_name| define_method(association_name) do association.read(self) end define_method(:"#{association_name}=") do |value| association.write(self, value) end end end |
#read(resource) ⇒ Object
29 30 31 |
# File 'lib/protip/resource/associations/association.rb', line 29 def read(resource) raise NotImplementedError end |
#resource_class ⇒ Object
Individual reference classes must implement
21 22 23 |
# File 'lib/protip/resource/associations/association.rb', line 21 def resource_class raise NotImplementedError end |
#write(resource, value) ⇒ Object
33 34 35 |
# File 'lib/protip/resource/associations/association.rb', line 33 def write(resource, value) raise NotImplementedError end |