Class: DotHash::Properties
- Inherits:
-
Object
- Object
- DotHash::Properties
show all
- Defined in:
- lib/dot_hash/properties.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
(also: #to_hash)
readonly
Returns the value of attribute hash.
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Properties.
6
7
8
|
# File 'lib/dot_hash/properties.rb', line 6
def initialize(hash)
@hash = hash
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *args, &block) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/dot_hash/properties.rb', line 10
def method_missing(key, *args, &block)
if has_key?(key)
execute(key, *args, &block)
else
super(key, *args, &block)
end
end
|
Instance Attribute Details
#hash ⇒ Object
Also known as:
to_hash
Returns the value of attribute hash.
3
4
5
|
# File 'lib/dot_hash/properties.rb', line 3
def hash
@hash
end
|
Instance Method Details
#[](key) ⇒ Object
30
31
32
|
# File 'lib/dot_hash/properties.rb', line 30
def [](key)
get_value(key)
end
|
#respond_to_missing?(key, *args) ⇒ Boolean
18
19
20
|
# File 'lib/dot_hash/properties.rb', line 18
def respond_to_missing?(key, *args)
has_key?(key) or super(key, *args)
end
|
#to_json ⇒ Object
26
27
28
|
# File 'lib/dot_hash/properties.rb', line 26
def to_json
hash.to_json
end
|
#to_s ⇒ Object
22
23
24
|
# File 'lib/dot_hash/properties.rb', line 22
def to_s
hash.to_s
end
|