Class: NullProperty
- Inherits:
-
Object
show all
- Defined in:
- lib/yaml_config/null_property.rb
Constant Summary
collapse
- @@base_values =
[{}, [], "", 0, 0.0, nil]
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *params) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/yaml_config/null_property.rb', line 40
def method_missing(name, *params)
@@base_values.each do |val|
return val.send(name, *params) if val.respond_to?(name)
end
super
end
|
Instance Method Details
#==(val) ⇒ Object
24
25
26
|
# File 'lib/yaml_config/null_property.rb', line 24
def ==(val)
super || @@base_values.any? { |v| v == val }
end
|
#[](key) ⇒ Object
28
29
30
|
# File 'lib/yaml_config/null_property.rb', line 28
def [](key)
NullProperty.new
end
|
#instance_of?(klass) ⇒ Boolean
32
33
34
|
# File 'lib/yaml_config/null_property.rb', line 32
def instance_of?(klass)
super || @@base_values.any? { |v| v.instance_of?(klass) }
end
|
#nil? ⇒ Boolean
20
21
22
|
# File 'lib/yaml_config/null_property.rb', line 20
def nil?
true
end
|
#respond_to?(method) ⇒ Boolean
36
37
38
|
# File 'lib/yaml_config/null_property.rb', line 36
def respond_to?(method)
super || @@base_values.any? { |v| v.respond_to?(method) }
end
|
#to_a ⇒ Object
16
17
18
|
# File 'lib/yaml_config/null_property.rb', line 16
def to_a
[]
end
|
#to_f ⇒ Object
12
13
14
|
# File 'lib/yaml_config/null_property.rb', line 12
def to_f
0.0
end
|
#to_i ⇒ Object
8
9
10
|
# File 'lib/yaml_config/null_property.rb', line 8
def to_i
0
end
|
#to_s ⇒ Object
4
5
6
|
# File 'lib/yaml_config/null_property.rb', line 4
def to_s
""
end
|