Class: AboutPage::Environment
- Inherits:
-
Configuration::Node
- Object
- Configuration::Node
- AboutPage::Environment
- Defined in:
- lib/about_page/environment.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#sections ⇒ Object
Returns the value of attribute sections.
Instance Method Summary collapse
- #env ⇒ Object
-
#initialize(sections = {}) ⇒ Environment
constructor
A new instance of Environment.
- #section_for(key, value) ⇒ Object
- #to_h ⇒ Object
Methods inherited from Configuration::Node
#add_header, #expects, #messages, #preflight, render_with, #set_headers!
Constructor Details
#initialize(sections = {}) ⇒ Environment
Returns a new instance of Environment.
5 6 7 |
# File 'lib/about_page/environment.rb', line 5 def initialize(sections = {}) self.sections = sections end |
Instance Attribute Details
#sections ⇒ Object
Returns the value of attribute sections.
3 4 5 |
# File 'lib/about_page/environment.rb', line 3 def sections @sections end |
Instance Method Details
#env ⇒ Object
9 10 11 |
# File 'lib/about_page/environment.rb', line 9 def env ENV end |
#section_for(key, value) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/about_page/environment.rb', line 27 def section_for(key, value) if sections.nil? nil else sections.keys.find do |k| key =~ sections[k] end end end |
#to_h ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/about_page/environment.rb', line 13 def to_h @request_env ||= begin h = Hash.new { |h,k| h[k] = {} } env.each_pair do |key,value| section = section_for(key,value) unless section.nil? h[section][key] = value if value.is_a? String end end h end end |