Module: RecordWithOperator::RelationMethods::InstanceMethods

Includes:
Utility
Defined in:
lib/record_with_operator/relation_methods.rb

Instance Method Summary collapse

Instance Method Details

#all(*args) ⇒ Object



57
58
59
# File 'lib/record_with_operator/relation_methods.rb', line 57

def all(*args)
  set_operator_to_records(super, operator)
end

#apply_finder_options(options) ⇒ Object



38
39
40
41
42
43
# File 'lib/record_with_operator/relation_methods.rb', line 38

def apply_finder_options(options)
  finders = options.dup
  operator = finders.delete(:for)
  relation = super(finders)
  relation.for(operator)
end

#except(*skips) ⇒ Object



20
21
22
23
24
# File 'lib/record_with_operator/relation_methods.rb', line 20

def except(*skips)
  result = super
  result.operator ||= operator
  result
end

#find(*args) ⇒ Object



45
46
47
# File 'lib/record_with_operator/relation_methods.rb', line 45

def find(*args)
  set_operator_to_records(super, operator)
end

#first(*args) ⇒ Object



49
50
51
# File 'lib/record_with_operator/relation_methods.rb', line 49

def first(*args)
  set_operator_to_records(super, operator)
end

#for(operator) ⇒ Object



32
33
34
35
36
# File 'lib/record_with_operator/relation_methods.rb', line 32

def for(operator)
  relation = clone
  relation.operator ||= operator
  relation
end

#last(*args) ⇒ Object



53
54
55
# File 'lib/record_with_operator/relation_methods.rb', line 53

def last(*args)
  set_operator_to_records(super, operator)
end

#merge(r) ⇒ Object



14
15
16
17
18
# File 'lib/record_with_operator/relation_methods.rb', line 14

def merge(r)
  merged_relation = super
  merged_relation.operator ||= r.operator
  merged_relation
end

#only(*onlies) ⇒ Object



26
27
28
29
30
# File 'lib/record_with_operator/relation_methods.rb', line 26

def only(*onlies)
  result = super
  result.operator ||= operator
  result
end

#to_aObject



61
62
63
# File 'lib/record_with_operator/relation_methods.rb', line 61

def to_a
  set_operator_to_records(super, operator)
end