Class: Frizz::Environment
- Inherits:
-
Object
- Object
- Frizz::Environment
- Defined in:
- lib/frizz/environment.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, data) ⇒ Environment
constructor
A new instance of Environment.
-
#method_missing(meth, args, &block) ⇒ Object
This is a creative way to allow for calling frizz.production? or frizz.staging? from the Middleman view helpers.
Constructor Details
#initialize(name, data) ⇒ Environment
Returns a new instance of Environment.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/frizz/environment.rb', line 5 def initialize(name, data) @name = name data.each do |attribute, value| ivar_name = "@#{attribute}" instance_variable_set(ivar_name, value) self.class.send :define_method, attribute do instance_variable_get(ivar_name) end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, args, &block) ⇒ Object
This is a creative way to allow for calling frizz.production? or frizz.staging? from the Middleman view helpers
20 21 22 |
# File 'lib/frizz/environment.rb', line 20 def method_missing(meth, args, &block) name == meth.to_s end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/frizz/environment.rb', line 3 def name @name end |