Module: RemoteResource::Concerns::Relation::ClassMethods

Defined in:
lib/remote_resource/concerns/relation.rb

Instance Method Summary collapse

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_relationObject



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_relationObject



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_mergedObject



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

#relationObject



9
10
11
# File 'lib/remote_resource/concerns/relation.rb', line 9

def relation
  @relation ||= RemoteResource::Model::Relation.for_model(self)
end