Class: HashMap::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_map/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, options = {})
  @original = _transforms_input(prepare_input(original))
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/hash_map/base.rb', line 17

def options
  @options
end

#originalObject (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

#mapperObject



23
24
25
# File 'lib/hash_map/base.rb', line 23

def mapper
  @mapper ||= Mapper.new(original, self)
end

#outputObject 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