Module: Renee::Core::EnvAccessors::ClassMethods
- Defined in:
- lib/renee_core/env_accessors.rb
Overview
Class-methods included by this module.
Instance Method Summary collapse
-
#env_accessor(*attrs) ⇒ Object
Defines getters and setters for a list of attributes.
-
#env_reader(*attrs) ⇒ Object
Defines getters for a list of attributes.
-
#env_writer(*attrs) ⇒ Object
Defines setters for a list of attributes.
Instance Method Details
#env_accessor(*attrs) ⇒ Object
Defines getters and setters for a list of attributes. If the attributes cannot easily be expressed, use the hash-syntax for defining them.
20 21 22 23 |
# File 'lib/renee_core/env_accessors.rb', line 20 def env_accessor(*attrs) env_reader(*attrs) env_writer(*attrs) end |
#env_reader(*attrs) ⇒ Object
Defines getters for a list of attributes.
27 28 29 30 31 32 33 34 35 |
# File 'lib/renee_core/env_accessors.rb', line 27 def env_reader(*attrs) instance_eval do env_attr_iter(*attrs) do |key, meth| define_method(meth) do env[key] end end end end |
#env_writer(*attrs) ⇒ Object
Defines setters for a list of attributes.
39 40 41 42 43 44 45 46 47 |
# File 'lib/renee_core/env_accessors.rb', line 39 def env_writer(*attrs) instance_eval do env_attr_iter(*attrs) do |key, meth| define_method("#{meth}=") do |val| env[key] = val end end end end |