Class: Fleakr::Objects::MetadataCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/fleakr/objects/metadata_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(photo) ⇒ MetadataCollection

Returns a new instance of MetadataCollection.



10
11
12
# File 'lib/fleakr/objects/metadata_collection.rb', line 10

def initialize(photo)
  @photo = photo
end

Instance Attribute Details

#photoObject (readonly)

Returns the value of attribute photo.



8
9
10
# File 'lib/fleakr/objects/metadata_collection.rb', line 8

def photo
  @photo
end

Instance Method Details

#[](key) ⇒ Object



25
26
27
# File 'lib/fleakr/objects/metadata_collection.rb', line 25

def [](key)
  data[key].raw
end

#dataObject



14
15
16
17
18
19
# File 'lib/fleakr/objects/metadata_collection.rb', line 14

def data
  @data ||= begin
    elements = Metadata.find_all_by_photo_id(photo.id)
    elements.inject({}) {|c, e| c.merge(e.label => e) }
  end
end

#each(&block) ⇒ Object



29
30
31
# File 'lib/fleakr/objects/metadata_collection.rb', line 29

def each(&block)
  data.each(&block)
end

#keysObject



21
22
23
# File 'lib/fleakr/objects/metadata_collection.rb', line 21

def keys
  data.keys
end