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.11"

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



22
23
24
25
26
# File 'lib/yaml_properties.rb', line 22

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

  super key, *args, &block
end

Instance Attribute Details

#dev_environmentObject

Returns the value of attribute dev_environment.



12
13
14
# File 'lib/yaml_properties.rb', line 12

def dev_environment
  @dev_environment
end

Instance Method Details

#override_attribute(attribute, value) ⇒ Object



29
30
31
32
33
34
# File 'lib/yaml_properties.rb', line 29

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
9
10
# File 'lib/yaml_properties.rb', line 6

def properties
  reset! if dev_environment

  @properties ||= load_properties.with_indifferent_access
end

#reset!Object



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

def reset!
  reset_properties
end

#reset_propertiesObject



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

def reset_properties
  @properties = nil
end