Class: Dist::Configuration::Section
- Inherits:
-
Object
- Object
- Dist::Configuration::Section
- Includes:
- Error
- Defined in:
- lib/dist/configuration.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
- #add_property(name, type, options = {}) ⇒ Object
-
#initialize(name) ⇒ Section
constructor
A new instance of Section.
- #string(name, options = {}) ⇒ Object
- #to_s ⇒ Object
Methods included from Error
Constructor Details
#initialize(name) ⇒ Section
Returns a new instance of Section.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dist/configuration.rb', line 63 def initialize(name) @name = name @properties = [] @filename = "config/#{name}.yml" unless File.exists?(@filename) error_at "config :#{name}", "the file '#{@filename}' doesn't exist." end @yaml = YAML.load_file @filename @yaml = @yaml['production'] || @yaml end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
60 61 62 |
# File 'lib/dist/configuration.rb', line 60 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
61 62 63 |
# File 'lib/dist/configuration.rb', line 61 def properties @properties end |
Instance Method Details
#add_property(name, type, options = {}) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/dist/configuration.rb', line 80 def add_property(name, type, = {}) unless @yaml.has_key?(name.to_s) error_at "#{type}: :#{name}", "the property '#{name}' inside the file '#{@filename} doesn't exist." end @properties << Property.new(self, name, type, ) end |
#string(name, options = {}) ⇒ Object
76 77 78 |
# File 'lib/dist/configuration.rb', line 76 def string(name, = {}) add_property name, :string, end |
#to_s ⇒ Object
88 89 90 |
# File 'lib/dist/configuration.rb', line 88 def to_s name.to_s end |