Module: RemoteResource::Concerns::Relation::ClassMethods
- Defined in:
- lib/remote_resource/concerns/relation.rb
Instance Method Summary collapse
- #collect_from_superclasses(variable_name) ⇒ Object
- #delegate_from_relation(*methods) ⇒ Object
- #delegate_to_relation(*methods) ⇒ Object
- #delegate_to_relation_merged(*methods) ⇒ Object
- #delegated_from_relation ⇒ Object
- #delegated_to_relation ⇒ Object
- #delegated_to_relation_merged ⇒ Object
- #relation ⇒ Object
Instance Method Details
#collect_from_superclasses(variable_name) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/remote_resource/concerns/relation.rb', line 42 def collect_from_superclasses(variable_name) methods = [] klass = self while klass do methods += Array.wrap(klass.instance_variable_get(variable_name)) klass = klass.superclass end methods end |
#delegate_from_relation(*methods) ⇒ Object
33 34 35 36 |
# File 'lib/remote_resource/concerns/relation.rb', line 33 def delegate_from_relation(*methods) @delegated_from_relation ||= [] @delegated_from_relation += methods end |
#delegate_to_relation(*methods) ⇒ Object
13 14 15 16 17 |
# File 'lib/remote_resource/concerns/relation.rb', line 13 def delegate_to_relation(*methods) @delegated_to_relation ||= [] @delegated_to_relation += methods single_delegate methods => :relation end |
#delegate_to_relation_merged(*methods) ⇒ Object
23 24 25 26 27 |
# File 'lib/remote_resource/concerns/relation.rb', line 23 def delegate_to_relation_merged(*methods) @delegated_to_relation_merged ||= [] @delegated_to_relation_merged += methods delegate_to_relation(*methods) end |
#delegated_from_relation ⇒ Object
38 39 40 |
# File 'lib/remote_resource/concerns/relation.rb', line 38 def delegated_from_relation collect_from_superclasses(:@delegated_from_relation) end |
#delegated_to_relation ⇒ Object
19 20 21 |
# File 'lib/remote_resource/concerns/relation.rb', line 19 def delegated_to_relation collect_from_superclasses(:@delegated_to_relation) end |
#delegated_to_relation_merged ⇒ Object
29 30 31 |
# File 'lib/remote_resource/concerns/relation.rb', line 29 def delegated_to_relation_merged collect_from_superclasses(:@delegated_to_relation_merged) end |
#relation ⇒ Object
9 10 11 |
# File 'lib/remote_resource/concerns/relation.rb', line 9 def relation @relation ||= RemoteResource::Model::Relation.for_model(self) end |