Class: AngularConfig::Source
- Inherits:
-
Object
- Object
- AngularConfig::Source
- Defined in:
- lib/angular_config/source.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content) ⇒ Source
constructor
A new instance of Source.
- #md5 ⇒ Object
- #resolve(hashed_keys) ⇒ Object
Constructor Details
#initialize(content) ⇒ Source
Returns a new instance of Source.
5 6 7 |
# File 'lib/angular_config/source.rb', line 5 def initialize(content) @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/angular_config/source.rb', line 3 def content @content end |
Class Method Details
.load(path) ⇒ Object
25 26 27 |
# File 'lib/angular_config/source.rb', line 25 def self.load(path) AngularConfig::Source.new AngularConfig::File.new(path).content end |
.save(data, path) ⇒ Object
29 30 31 |
# File 'lib/angular_config/source.rb', line 29 def self.save(data, path) AngularConfig::File.new(path).content = data end |
Instance Method Details
#md5 ⇒ Object
9 10 11 |
# File 'lib/angular_config/source.rb', line 9 def md5 Digest::MD5.hexdigest(content) end |
#resolve(hashed_keys) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/angular_config/source.rb', line 13 def resolve(hashed_keys) hashed_keys.content.each do |key, value| if value.is_a?(String) self.content.gsub!(key, value) else self.content.gsub!("\"#{key}\"", value.to_json) end end self end |