Class: DmAdapterSimpledb::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/dm-adapter-simpledb/table.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Table

Returns a new instance of Table.



17
18
19
# File 'lib/dm-adapter-simpledb/table.rb', line 17

def initialize(model)
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



15
16
17
# File 'lib/dm-adapter-simpledb/table.rb', line 15

def model
  @model
end

Class Method Details

.name_from_metadata(metadata) ⇒ Object



4
5
6
7
8
9
# File 'lib/dm-adapter-simpledb/table.rb', line 4

def self.()
  Array().grep(/^table:(.*)$/) do |match|
    return $1
  end
  nil
end

.token_for(name) ⇒ Object



11
12
13
# File 'lib/dm-adapter-simpledb/table.rb', line 11

def self.token_for(name)
  "table:#{name}"
end

Instance Method Details

#keys_for_modelObject

Returns the keys for model sorted in alphabetical order



33
34
35
# File 'lib/dm-adapter-simpledb/table.rb', line 33

def keys_for_model
  model.key(repository_name).sort {|a,b| a.name.to_s <=> b.name.to_s }
end

#repository_nameObject



27
28
29
30
# File 'lib/dm-adapter-simpledb/table.rb', line 27

def repository_name
  # TODO this should probably take into account the adapter
  model.repository.name
end

#simpledb_typeObject Also known as: storage_name

Returns a string so we know what type of



22
23
24
# File 'lib/dm-adapter-simpledb/table.rb', line 22

def simpledb_type
  model.storage_name(DataMapper.repository.name)
end

#tokenObject



37
38
39
# File 'lib/dm-adapter-simpledb/table.rb', line 37

def token
  self.class.token_for(simpledb_type)
end