Class: Jacoat::Document::Attributes
- Inherits:
-
Object
- Object
- Jacoat::Document::Attributes
- Defined in:
- lib/jacoat/document/attribute.rb
Instance Method Summary collapse
-
#initialize(arguments = {}) ⇒ Attributes
constructor
A new instance of Attributes.
- #method_missing(m, *args) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(arguments = {}) ⇒ Attributes
Returns a new instance of Attributes.
4 5 6 |
# File 'lib/jacoat/document/attribute.rb', line 4 def initialize(arguments = {}) @hash = arguments end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/jacoat/document/attribute.rb', line 8 def method_missing(m, *args) #setter if /^(\w+)=$/ =~ m @hash[:"#{$1}"] = args[0] end #getter @hash[:"#{m}"] end |
Instance Method Details
#to_hash ⇒ Object
17 18 19 |
# File 'lib/jacoat/document/attribute.rb', line 17 def to_hash proc = Proc.new { |k, v| v.kind_of?(Hash) ? (v.delete_if(&proc); nil) : v.nil? }; @hash.delete_if(&proc) end |