Module: YamlProperties

Extended by:
YamlProperties
Included in:
YamlProperties
Defined in:
lib/yaml_properties.rb,
lib/yaml_properties/version.rb

Defined Under Namespace

Classes: Diff

Constant Summary collapse

VERSION =
"0.0.10"

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, *args, &block) ⇒ Object



18
19
20
21
22
# File 'lib/yaml_properties.rb', line 18

def method_missing(key, *args, &block)
  return properties[key] if key_present? key

  super key, *args, &block
end

Instance Method Details

#override_attribute(attribute, value) ⇒ Object



25
26
27
28
29
30
# File 'lib/yaml_properties.rb', line 25

def override_attribute attribute, value
  unless key_present? attribute
    raise ArgumentError, "Trying to override non-existent property `#{attribute}' with `#{value}'"
  end
  properties[attribute] = value
end

#propertiesObject



6
7
8
# File 'lib/yaml_properties.rb', line 6

def properties
  @properties ||= load_properties.with_indifferent_access
end

#reset!Object



10
11
12
# File 'lib/yaml_properties.rb', line 10

def reset!
  reset_properties
end

#reset_propertiesObject



14
15
16
# File 'lib/yaml_properties.rb', line 14

def reset_properties
  @properties = nil
end