Class: Toggle
- Inherits:
-
Object
- Object
- Toggle
- Defined in:
- lib/toggle/parser/yaml.rb,
lib/toggle.rb,
lib/toggle/parser.rb,
lib/toggle/version.rb,
lib/toggle/compiler.rb
Overview
YAML Parser handles erb parsing first, then loads the content to yaml
Defined Under Namespace
Modules: Parser Classes: Compiler
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Attribute Summary collapse
-
#config_filepath ⇒ Object
Returns the value of attribute config_filepath.
-
#config_parsers ⇒ Object
Returns the value of attribute config_parsers.
- #key ⇒ Object
-
#key_filepath ⇒ Object
Returns the value of attribute key_filepath.
-
#key_parsers ⇒ Object
Returns the value of attribute key_parsers.
Instance Method Summary collapse
- #[](attribute) ⇒ Object
- #config ⇒ Object
- #configs ⇒ Object
-
#initialize(attributes = {}) ⇒ Toggle
constructor
A new instance of Toggle.
- #using(temporary_key) {|_self| ... } ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Toggle
Returns a new instance of Toggle.
14 15 16 17 18 |
# File 'lib/toggle.rb', line 14 def initialize attributes = {} attributes.keys.each do |attribute| self.send "#{attribute}=", attributes[attribute] end end |
Instance Attribute Details
#config_filepath ⇒ Object
Returns the value of attribute config_filepath.
12 13 14 |
# File 'lib/toggle.rb', line 12 def config_filepath @config_filepath end |
#config_parsers ⇒ Object
Returns the value of attribute config_parsers.
11 12 13 |
# File 'lib/toggle.rb', line 11 def config_parsers @config_parsers end |
#key ⇒ Object
29 30 31 |
# File 'lib/toggle.rb', line 29 def key (@key || key_from_file).try(:to_sym) end |
#key_filepath ⇒ Object
Returns the value of attribute key_filepath.
10 11 12 |
# File 'lib/toggle.rb', line 10 def key_filepath @key_filepath end |
#key_parsers ⇒ Object
Returns the value of attribute key_parsers.
9 10 11 |
# File 'lib/toggle.rb', line 9 def key_parsers @key_parsers end |
Instance Method Details
#[](attribute) ⇒ Object
20 21 22 |
# File 'lib/toggle.rb', line 20 def [] attribute config[attribute] end |
#config ⇒ Object
33 34 35 |
# File 'lib/toggle.rb', line 33 def config configs[key] end |
#configs ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/toggle.rb', line 37 def configs return @configs if defined?(@configs) && configs_clean? @configs = HashWithIndifferentAccess.new( Toggle::Compiler.new( config_filepath, config_parsers ).parsed_content ) configs_clean! @configs end |
#using(temporary_key) {|_self| ... } ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/toggle.rb', line 50 def using temporary_key return unless block_given? previous_key, self.key = self.key, temporary_key yield self self.key = previous_key end |