lib/about_page/configuration.rb in about_page-0.0.1 vs lib/about_page/configuration.rb in about_page-0.0.2
- old
+ new
@@ -6,10 +6,18 @@
delegate :each, :map, :to => :to_h
def to_json(options = {})
Hash[*@table.map { |k, v| [k, (v.to_h if v.respond_to? :to_h || v) ] }.flatten ]
end
+ def reject &block
+ self.class.new to_h.reject(&block)
+ end
+
+ def select &block
+ self.class.new to_h.select(&block)
+ end
+
def to_xml(options = {})
@table
end
def to_h
@@ -20,14 +28,22 @@
class Configuration
attr_accessor :hash
delegate :to_xml, :to_h, :to_json, :to => :hash
delegate :each, :map, :to => :to_h
- def initialize
- @hash = OpenStructWithHashAccess.new
+ def initialize hash = nil
+ @hash = hash || OpenStructWithHashAccess.new
end
+ def reject &block
+ AboutPage::Configuration.new @hash.reject(&block)
+ end
+
+ def select &block
+ AboutPage::Configuration.new @hash.select(&block)
+ end
+
def method_missing *args
@hash.send(*args)
end
def preflight request
@@ -50,20 +66,24 @@
def preflight request
end
def set_headers! response
-
+ messages.each { |m| add_header(response, m) }
end
def add_header response, text
response.headers['X-AboutPage-Warning'] ||= ""
response.headers['X-AboutPage-Warning'] += "#{text};"
end
def ok?
true
+ end
+
+ def messages
+ []
end
end
end
end