Class: SeedFu::BlockHash
- Inherits:
-
Object
- Object
- SeedFu::BlockHash
- Defined in:
- lib/seed-fu/block_hash.rb
Instance Method Summary collapse
-
#initialize(proc) ⇒ BlockHash
constructor
A new instance of BlockHash.
- #method_missing(method_name, *args, &block) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(proc) ⇒ BlockHash
Returns a new instance of BlockHash.
4 5 6 7 |
# File 'lib/seed-fu/block_hash.rb', line 4 def initialize(proc) @hash = {} proc.call(self) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/seed-fu/block_hash.rb', line 13 def method_missing(method_name, *args, &block) if method_name.to_s =~ /^(.*)=$/ && args.length == 1 && block.nil? @hash[$1] = args.first else super end end |
Instance Method Details
#to_hash ⇒ Object
9 10 11 |
# File 'lib/seed-fu/block_hash.rb', line 9 def to_hash @hash end |