Sha256: 752cc0034e1c8fae1b013d5e7265e5775c72ab8d049b4403362717b9a8815b83

Contents?: true

Size: 811 Bytes

Versions: 3

Compression:

Stored size: 811 Bytes

Contents

module DmAdapterSimpledb
  class Table

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

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

    attr_reader :model

    def initialize(model)
      @model = model
    end

    # Returns a string so we know what type of
    def simpledb_type
      model.storage_name(repository_name)
    end

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

    # Returns the keys for model sorted in alphabetical order
    def keys_for_model
      model.key(repository_name).sort {|a,b| a.name.to_s <=> b.name.to_s }
    end

    def token
      self.class.token_for(simpledb_type)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dm-adapter-simpledb-1.3.0 lib/dm-adapter-simpledb/table.rb
dm-adapter-simpledb-1.2.0 lib/dm-adapter-simpledb/table.rb
dm-adapter-simpledb-1.1.0 lib/dm-adapter-simpledb/table.rb