Class: Momo::BlockHash

Inherits:
Object
  • Object
show all
Defined in:
lib/momo/momoscope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, &block) ⇒ BlockHash

Returns a new instance of BlockHash.



7
8
9
10
11
# File 'lib/momo/momoscope.rb', line 7

def initialize(options, &block)
	@options = options
	@props = {}
	instance_eval(&block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



13
14
15
16
17
18
# File 'lib/momo/momoscope.rb', line 13

def method_missing(name, *args, &block)
	if /^[[:upper:]]/.match(name) == nil
		raise "Invalid property name: #{name}"
	end
	@props[name] = Momo.resolve(args[0], @options, &block)
end

Instance Attribute Details

#propsObject

Returns the value of attribute props.



6
7
8
# File 'lib/momo/momoscope.rb', line 6

def props
  @props
end