Module: Obscured::Timeline::Service::Base

Defined in:
lib/obscured-timeline/service.rb

Defined Under Namespace

Classes: Record

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/obscured-timeline/service.rb', line 7

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#all(criterion = {}) ⇒ Object



11
12
13
14
15
# File 'lib/obscured-timeline/service.rb', line 11

def all(criterion = {})
  Record.with(collection: "#{self.class.name.demodulize.downcase}_timeline") do |m|
    m.all(criterion).to_a
  end
end

#by(params = {}, options = {}) ⇒ Object



35
36
37
38
39
# File 'lib/obscured-timeline/service.rb', line 35

def by(params = {}, options = {})
  Record.with(collection: "#{self.class.name.demodulize.downcase}_timeline") do |m|
    m.by(params, options)
  end
end

#delete(id) ⇒ Object



41
42
43
44
45
# File 'lib/obscured-timeline/service.rb', line 41

def delete(id)
  Record.with(collection: "#{self.class.name.demodulize.downcase}_timeline") do |m|
    m.where(id: id).delete
  end
end

#find(*args) ⇒ Object



17
18
19
20
21
# File 'lib/obscured-timeline/service.rb', line 17

def find(*args)
  Record.with(collection: "#{self.class.name.demodulize.downcase}_timeline") do |m|
    m.find(*args)
  end
end

#find_by(attrs = {}) ⇒ Object



23
24
25
26
27
# File 'lib/obscured-timeline/service.rb', line 23

def find_by(attrs = {})
  Record.with(collection: "#{self.class.name.demodulize.downcase}_timeline") do |m|
    m.find_by(attrs).to_a
  end
end

#where(expression) ⇒ Object



29
30
31
32
33
# File 'lib/obscured-timeline/service.rb', line 29

def where(expression)
  Record.with(collection: "#{self.class.name.demodulize.downcase}_timeline") do |m|
    m.where(expression).to_a
  end
end