Module: DHS::Record::Chainable::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#all(hash = nil) ⇒ Object



29
30
31
32
33
# File 'lib/dhs/concerns/record/chainable.rb', line 29

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

#expanded(options = nil) ⇒ Object



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

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

#fetchObject



25
26
27
# File 'lib/dhs/concerns/record/chainable.rb', line 25

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

#ignore(*error_classes) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/dhs/concerns/record/chainable.rb', line 59

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



71
72
73
74
75
# File 'lib/dhs/concerns/record/chainable.rb', line 71

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

#includes_first_page(*args) ⇒ Object



67
68
69
# File 'lib/dhs/concerns/record/chainable.rb', line 67

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

#limit(argument = nil) ⇒ Object



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

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

#options(hash = nil) ⇒ Object



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

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

#page(page) ⇒ Object



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

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

#per(limit) ⇒ Object



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

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

#references(*args) ⇒ Object



77
78
79
# File 'lib/dhs/concerns/record/chainable.rb', line 77

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

#rescue(error_class, handler) ⇒ Object



55
56
57
# File 'lib/dhs/concerns/record/chainable.rb', line 55

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

#where(args = nil) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/dhs/concerns/record/chainable.rb', line 17

def where(args = nil)
  if href?(args)
    Chain.new(self, Option.new(url: args))
  else
    Chain.new(self, Parameter.new(args))
  end
end