Class: AboutPage::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/about_page/configuration.rb

Defined Under Namespace

Classes: Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ Configuration

Returns a new instance of Configuration.



33
34
35
# File 'lib/about_page/configuration.rb', line 33

def initialize hash = nil
  @hash = hash || OpenStructWithHashAccess.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



45
46
47
# File 'lib/about_page/configuration.rb', line 45

def method_missing *args
  @hash.send(*args)
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



29
30
31
# File 'lib/about_page/configuration.rb', line 29

def hash
  @hash
end

Instance Method Details

#nodesObject



57
58
59
# File 'lib/about_page/configuration.rb', line 57

def nodes
  self.to_h.select { |key, profile| profile.is_a? AboutPage::Configuration::Node }
end

#preflight(request) ⇒ Object



49
50
51
# File 'lib/about_page/configuration.rb', line 49

def preflight request
  self.nodes.each { |key, profile| profile.preflight(request) }
end

#reject(&block) ⇒ Object



37
38
39
# File 'lib/about_page/configuration.rb', line 37

def reject &block
  AboutPage::Configuration.new @hash.reject(&block)
end

#select(&block) ⇒ Object



41
42
43
# File 'lib/about_page/configuration.rb', line 41

def select &block
  AboutPage::Configuration.new @hash.select(&block)
end

#set_headers!(response) ⇒ Object



61
62
63
# File 'lib/about_page/configuration.rb', line 61

def set_headers! response
  self.nodes.each { |key, profile| profile.set_headers! response }
end

#valid?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/about_page/configuration.rb', line 53

def valid?
   self.nodes.select { |key, profile| profile.respond_to? :ok? }.all? { |key, profile| profile.valid? }
end