Module: Chassis::Repo::Delegation

Defined in:
lib/chassis/repo/delegation.rb

Instance Method Summary collapse

Instance Method Details

#allObject



8
9
10
# File 'lib/chassis/repo/delegation.rb', line 8

def all
  backend.all object_class
end

#backendObject



77
78
79
# File 'lib/chassis/repo/delegation.rb', line 77

def backend
  Repo.default
end

#countObject



16
17
18
# File 'lib/chassis/repo/delegation.rb', line 16

def count
  backend.count object_class
end

#delete(record) ⇒ Object



28
29
30
# File 'lib/chassis/repo/delegation.rb', line 28

def delete(record)
  backend.delete record
end

#each(&block) ⇒ Object



12
13
14
# File 'lib/chassis/repo/delegation.rb', line 12

def each(&block)
  backend.each object_class, &block
end

#empty?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/chassis/repo/delegation.rb', line 52

def empty?
  backend.empty? object_class
end

#find(id) ⇒ Object



20
21
22
# File 'lib/chassis/repo/delegation.rb', line 20

def find(id)
  backend.find object_class, id
end

#firstObject



32
33
34
# File 'lib/chassis/repo/delegation.rb', line 32

def first
  backend.first object_class
end

#graph(id) ⇒ Object



56
57
58
# File 'lib/chassis/repo/delegation.rb', line 56

def graph(id)
  backend.graph object_class, id
end

#graph_query(selector) ⇒ Object



60
61
62
# File 'lib/chassis/repo/delegation.rb', line 60

def graph_query(selector)
  backend.graph_query object_class, selector
end

#lastObject



36
37
38
# File 'lib/chassis/repo/delegation.rb', line 36

def last
  backend.last object_class
end

#lazy(id) ⇒ Object



64
65
66
# File 'lib/chassis/repo/delegation.rb', line 64

def lazy(id)
  LazyAssociation.new self, id
end

#object_classObject



68
69
70
71
72
73
74
75
# File 'lib/chassis/repo/delegation.rb', line 68

def object_class
  @object_class ||= begin
    fail UnknownObjectClassError unless name
    match = name.match(/^(.+)Repo$/)
    fail UnknownObjectClassError unless match
    StringUtils.constantize match[1]
  end
end

#query(selector) ⇒ Object



40
41
42
# File 'lib/chassis/repo/delegation.rb', line 40

def query(selector)
  backend.query object_class, selector
end

#query!(selector, &block) ⇒ Object



44
45
46
# File 'lib/chassis/repo/delegation.rb', line 44

def query!(selector, &block)
  backend.query! object_class, selector, &block
end

#sampleObject



48
49
50
# File 'lib/chassis/repo/delegation.rb', line 48

def sample
  backend.sample object_class
end

#save(record) ⇒ Object



24
25
26
# File 'lib/chassis/repo/delegation.rb', line 24

def save(record)
  backend.save(record)
end