Class: Appfuel::Repository::StorageMap
- Inherits:
-
Object
- Object
- Appfuel::Repository::StorageMap
- Defined in:
- lib/appfuel/storage/repository/storage_map.rb
Instance Attribute Summary collapse
-
#container_name ⇒ Object
readonly
Returns the value of attribute container_name.
-
#domain_name ⇒ Object
readonly
Returns the value of attribute domain_name.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#storage_key ⇒ Object
readonly
Returns the value of attribute storage_key.
-
#storage_type ⇒ Object
readonly
Returns the value of attribute storage_type.
Instance Method Summary collapse
- #domain_attr(storage_attr) ⇒ Object
- #each ⇒ Object
-
#initialize(data) ⇒ StorageMap
constructor
A new instance of StorageMap.
- #storage_attr(domain_attr) ⇒ Object
Constructor Details
#initialize(data) ⇒ StorageMap
Returns a new instance of StorageMap.
7 8 9 10 11 12 13 14 15 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 7 def initialize(data) fail "Mapping data must be a hash" unless data.is_a?(Hash) @container_name = data[:container] @domain_name = data.fetch(:domain_name) { domain_name_failure }.to_s @storage_type = data.fetch(:storage_type) { storage_type_failure } @storage_key = data.fetch(:storage_key) { storage_key_failure } @entries = data.fetch(:entries) { entries_failure } end |
Instance Attribute Details
#container_name ⇒ Object (readonly)
Returns the value of attribute container_name.
4 5 6 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 4 def container_name @container_name end |
#domain_name ⇒ Object (readonly)
Returns the value of attribute domain_name.
4 5 6 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 4 def domain_name @domain_name end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
4 5 6 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 4 def entries @entries end |
#storage_key ⇒ Object (readonly)
Returns the value of attribute storage_key.
4 5 6 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 4 def storage_key @storage_key end |
#storage_type ⇒ Object (readonly)
Returns the value of attribute storage_type.
4 5 6 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 4 def storage_type @storage_type end |
Instance Method Details
#domain_attr(storage_attr) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 25 def domain_attr(storage_attr) entries.each do |data| return data[:domain_attr] if data[:storage_attr] == storage_attr end fail "[storage_map #{domain_name}] #{storage_attr} not registered" end |
#each ⇒ Object
33 34 35 36 37 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 33 def each entries.each do |data| yield data[:domain_attr], data[:storage_attr], data[:skip] end end |
#storage_attr(domain_attr) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/appfuel/storage/repository/storage_map.rb', line 17 def storage_attr(domain_attr) entries.each do |data| return data[:storage_attr] if data[:domain_attr] == domain_attr end fail "[storage_map #{domain_name}] #{domain_attr} not registered" end |