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.
24 25 26 27 |
# File 'lib/hash_map/base.rb', line 24 def initialize(original, = {}) @original = _transforms_input(prepare_input(original)) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/hash_map/base.rb', line 23 def @options end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
23 24 25 |
# File 'lib/hash_map/base.rb', line 23 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.deep_dup) end end |
.map(*args) ⇒ Object
4 5 6 |
# File 'lib/hash_map/base.rb', line 4 def self.map(*args) new(*args).output end |
.only_provided_call(*args) ⇒ Object
17 18 19 20 21 |
# File 'lib/hash_map/base.rb', line 17 def self.only_provided_call(*args) Class.new(self) do only_provided_keys end.call(*args) end |
Instance Method Details
#[](key) ⇒ Object
42 43 44 |
# File 'lib/hash_map/base.rb', line 42 def [](key) output[key] end |
#mapper ⇒ Object
29 30 31 |
# File 'lib/hash_map/base.rb', line 29 def mapper @mapper ||= Mapper.new(original, self) end |
#output ⇒ Object Also known as: to_h, to_hash, call, execute
33 34 35 |
# File 'lib/hash_map/base.rb', line 33 def output @output ||= _transforms_output(mapper.output) end |