Class: Jasonette::Helpers::BlockBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/jasonette/helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ BlockBuilder

Returns a new instance of BlockBuilder.



16
17
18
# File 'lib/jasonette/helpers.rb', line 16

def initialize builder
  @builder = builder
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



20
21
22
23
24
# File 'lib/jasonette/helpers.rb', line 20

def method_missing name, *args, &block
  next_builder = builder.public_send name, *args
  j.encode(next_builder, &block) if ::Kernel.block_given?
  next_builder
end

Instance Attribute Details

#builderObject (readonly)

Returns the value of attribute builder.



15
16
17
# File 'lib/jasonette/helpers.rb', line 15

def builder
  @builder
end