Class: SeedFu::BlockHash

Inherits:
Object
  • Object
show all
Defined in:
lib/seed-fu/block_hash.rb

Instance Method Summary collapse

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_hashObject



9
10
11
# File 'lib/seed-fu/block_hash.rb', line 9

def to_hash
  @hash
end