Class: HashMap::Base
- Inherits:
-
Object
- Object
- HashMap::Base
- Defined in:
- lib/hash_map/base.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(original, options = {}) ⇒ Base
constructor
A new instance of Base.
- #mapper ⇒ Object
- #output ⇒ Object (also: #to_h, #to_hash, #call, #execute)
Constructor Details
#initialize(original, options = {}) ⇒ Base
Returns a new instance of Base.
18 19 20 21 |
# File 'lib/hash_map/base.rb', line 18 def initialize(original, = {}) @original = _transforms_input(prepare_input(original)) = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/hash_map/base.rb', line 17 def end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
17 18 19 |
# File 'lib/hash_map/base.rb', line 17 def original @original end |
Class Method Details
.inherited(subclass) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/hash_map/base.rb', line 9 def self.inherited(subclass) subclass.extend ToDSL return unless self < HashMap::Base unless dsl.attributes.empty? subclass._set_attributes_from_inheritance(attributes) end end |
.map(*args) ⇒ Object
4 5 6 |
# File 'lib/hash_map/base.rb', line 4 def self.map(*args) new(*args).output end |
Instance Method Details
#[](key) ⇒ Object
36 37 38 |
# File 'lib/hash_map/base.rb', line 36 def [](key) output[key] end |
#mapper ⇒ Object
23 24 25 |
# File 'lib/hash_map/base.rb', line 23 def mapper @mapper ||= Mapper.new(original, self) end |
#output ⇒ Object Also known as: to_h, to_hash, call, execute
27 28 29 |
# File 'lib/hash_map/base.rb', line 27 def output @output ||= _transforms_output(mapper.output) end |