Class: Whisperer::Headers
- Inherits:
-
Object
- Object
- Whisperer::Headers
- Defined in:
- lib/whisperer/record/headers.rb
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Headers
constructor
A new instance of Headers.
- #to_hash ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Headers
Returns a new instance of Headers.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/whisperer/record/headers.rb', line 5 def initialize(attrs = {}) extend Virtus.model attrs.each do |attr, val| self.attribute(attr.to_sym, Object) self.public_send("#{attr}=", val) end super end |
Instance Method Details
#to_hash ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/whisperer/record/headers.rb', line 16 def to_hash prepared_attrs, attrs = {}, super attrs.each do |key, val| key = key.to_s.titleize.split(' ').join('-') prepared_attrs[key] = val end prepared_attrs end |