Class: Appfuel::Repository::MappingEntry
- Inherits:
-
Object
- Object
- Appfuel::Repository::MappingEntry
- Defined in:
- lib/appfuel/storage/repository/mapping_entry.rb
Instance Attribute Summary collapse
-
#container_key ⇒ Object
readonly
Returns the value of attribute container_key.
-
#container_name ⇒ Object
readonly
Returns the value of attribute container_name.
-
#domain_attr ⇒ Object
readonly
Returns the value of attribute domain_attr.
-
#domain_name ⇒ Object
readonly
Returns the value of attribute domain_name.
-
#storage_attr ⇒ Object
readonly
Returns the value of attribute storage_attr.
Instance Method Summary collapse
- #computed_attr(value, domain) ⇒ Object
- #computed_attr? ⇒ Boolean
-
#initialize(data) ⇒ MappingEntry
constructor
A new instance of MappingEntry.
- #skip? ⇒ Boolean
- #storage(type) ⇒ Object
- #storage?(type) ⇒ Boolean
Constructor Details
#initialize(data) ⇒ MappingEntry
Returns a new instance of MappingEntry.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 7 def initialize(data) unless data.respond_to?(:to_h) fail "Map entry data must respond to :to_h" end data = data.to_h @domain_name = data.fetch(:domain_name) { fail "Fully qualified domain name is required" }.to_s @storage = data.fetch(:storage) { fail "Storage classes hash is required" } @storage_attr = data.fetch(:storage_attr) { fail "Storage attribute is required" }.to_s @domain_attr = data.fetch(:domain_attr) { fail "Domain attribute is required" } @skip = data[:skip] == true ? true : false if data.key?(:computed_attr) computed_attr_lambda(data[:computed_attr]) end @container_name = data[:container] @container_key = "mappings.#{domain_name}.#{domain_attr}" end |
Instance Attribute Details
#container_key ⇒ Object (readonly)
Returns the value of attribute container_key.
4 5 6 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 4 def container_key @container_key end |
#container_name ⇒ Object (readonly)
Returns the value of attribute container_name.
4 5 6 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 4 def container_name @container_name end |
#domain_attr ⇒ Object (readonly)
Returns the value of attribute domain_attr.
4 5 6 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 4 def domain_attr @domain_attr end |
#domain_name ⇒ Object (readonly)
Returns the value of attribute domain_name.
4 5 6 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 4 def domain_name @domain_name end |
#storage_attr ⇒ Object (readonly)
Returns the value of attribute storage_attr.
4 5 6 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 4 def storage_attr @storage_attr end |
Instance Method Details
#computed_attr(value, domain) ⇒ Object
57 58 59 60 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 57 def computed_attr(value, domain) fail "No lambda assigned to compute value" unless computed_attr? @computed_attr.call(value, domain) end |
#computed_attr? ⇒ Boolean
53 54 55 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 53 def computed_attr? !@computed_attr.nil? end |
#skip? ⇒ Boolean
49 50 51 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 49 def skip? @skip end |
#storage(type) ⇒ Object
39 40 41 42 43 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 39 def storage(type) fail "Storage #{type} is not registered" unless storage?(type) @storage[type] end |
#storage?(type) ⇒ Boolean
45 46 47 |
# File 'lib/appfuel/storage/repository/mapping_entry.rb', line 45 def storage?(type) @storage.key?(type) end |