Module: Ricordami::IsRetrievable::ClassMethods

Defined in:
lib/ricordami/is_retrievable.rb

Instance Method Summary collapse

Instance Method Details

#all(expressions = nil) ⇒ Object



25
26
27
28
# File 'lib/ricordami/is_retrievable.rb', line 25

def all(expressions = nil)
  ids = indices[:u_id].all
  ids.map { |id| get(id) }
end

#countObject



30
31
32
# File 'lib/ricordami/is_retrievable.rb', line 30

def count
  indices[:u_id].count
end

#get(id) ⇒ Object Also known as: []

Raises:



13
14
15
16
17
18
19
20
21
22
# File 'lib/ricordami/is_retrievable.rb', line 13

def get(id)
  attributes = load_attributes_for(id)
  raise NotFound.new("id = #{id}") if attributes.empty?
  new(attributes).tap do |instance|
    instance.instance_eval do
      @persisted = true
      attributes_synced_with_db!
    end
  end
end