Class: DotHash::Properties

Inherits:
Object
  • Object
show all
Defined in:
lib/dot_hash/properties.rb

Direct Known Subclasses

Settings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Properties

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

#hashObject (readonly) 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

Returns:

  • (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_jsonObject



26
27
28
# File 'lib/dot_hash/properties.rb', line 26

def to_json
  hash.to_json
end

#to_sObject



22
23
24
# File 'lib/dot_hash/properties.rb', line 22

def to_s
  hash.to_s
end