Module: LHS::Record::Chainable::ClassMethods

Defined in:
lib/lhs/concerns/record/chainable.rb

Instance Method Summary collapse

Instance Method Details

#all(hash = nil) ⇒ Object



25
26
27
28
29
# File 'lib/lhs/concerns/record/chainable.rb', line 25

def all(hash = nil)
  chain = Chain.new(self, Parameter.new(hash))
  chain._links.push(Option.new(all: true))
  chain
end

#expanded(options = nil) ⇒ Object



31
32
33
# File 'lib/lhs/concerns/record/chainable.rb', line 31

def expanded(options = nil)
  Chain.new(self, Option.new(expanded: options || true))
end

#fetchObject



21
22
23
# File 'lib/lhs/concerns/record/chainable.rb', line 21

def fetch
  Chain.new(self, nil).fetch
end

#handle(error_class, handler) ⇒ Object



51
52
53
# File 'lib/lhs/concerns/record/chainable.rb', line 51

def handle(error_class, handler)
  Chain.new(self, ErrorHandling.new(error_class => handler))
end

#ignore(*error_classes) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/lhs/concerns/record/chainable.rb', line 55

def ignore(*error_classes)
  chain = Chain.new(self, IgnoredError.new(error_classes.shift))
  error_classes.each do |error_class|
    chain._links.push(IgnoredError.new(error_class))
  end
  chain
end

#includes(*args) ⇒ Object



63
64
65
# File 'lib/lhs/concerns/record/chainable.rb', line 63

def includes(*args)
  Chain.new(self, Include.new(Chain.unfold(args)))
end

#includes_all(*args) ⇒ Object



67
68
69
70
71
# File 'lib/lhs/concerns/record/chainable.rb', line 67

def includes_all(*args)
  chain = Chain.new(self, Include.new(Chain.unfold(args)))
  chain.include_all!(args)
  chain
end

#limit(argument = nil) ⇒ Object



47
48
49
# File 'lib/lhs/concerns/record/chainable.rb', line 47

def limit(argument = nil)
  Chain.new(self, Pagination.new(per: argument))
end

#options(hash = nil) ⇒ Object



35
36
37
# File 'lib/lhs/concerns/record/chainable.rb', line 35

def options(hash = nil)
  Chain.new(self, Option.new(hash))
end

#page(page) ⇒ Object



39
40
41
# File 'lib/lhs/concerns/record/chainable.rb', line 39

def page(page)
  Chain.new(self, Pagination.new(page: page))
end

#per(limit) ⇒ Object



43
44
45
# File 'lib/lhs/concerns/record/chainable.rb', line 43

def per(limit)
  Chain.new(self, Pagination.new(per: limit))
end

#references(*args) ⇒ Object



73
74
75
# File 'lib/lhs/concerns/record/chainable.rb', line 73

def references(*args)
  Chain.new(self, Reference.new(Chain.unfold(args)))
end

#where(hash = nil) ⇒ Object



17
18
19
# File 'lib/lhs/concerns/record/chainable.rb', line 17

def where(hash = nil)
  Chain.new(self, Parameter.new(hash))
end