Class: MaybeHash

Inherits:
Object
  • Object
show all
Defined in:
lib/maybe_hash.rb,
lib/maybe_hash/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ MaybeHash

Returns a new instance of MaybeHash.



7
8
9
# File 'lib/maybe_hash.rb', line 7

def initialize(value)
  @value = value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(attribute) ⇒ Object



11
12
13
# File 'lib/maybe_hash.rb', line 11

def method_missing(attribute)
  self.class.new(choose_value(attribute))
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/maybe_hash.rb', line 5

def value
  @value
end