Class: IfBindingSetup
- Inherits:
-
BindingSetup
- Object
- BindingSetup
- IfBindingSetup
- Defined in:
- lib/volt/server/if_binding_setup.rb
Instance Method Summary collapse
- #add_branch(content, template_name) ⇒ Object
-
#initialize ⇒ IfBindingSetup
constructor
A new instance of IfBindingSetup.
- #to_setup_code ⇒ Object
Constructor Details
#initialize ⇒ IfBindingSetup
Returns a new instance of IfBindingSetup.
7 8 9 |
# File 'lib/volt/server/if_binding_setup.rb', line 7 def initialize @branches = [] end |
Instance Method Details
#add_branch(content, template_name) ⇒ Object
11 12 13 |
# File 'lib/volt/server/if_binding_setup.rb', line 11 def add_branch(content, template_name) @branches << [content, template_name] end |
#to_setup_code ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/volt/server/if_binding_setup.rb', line 15 def to_setup_code branches = @branches.map do |branch| content = branch[0] if content == nil content = nil.inspect else content = "Proc.new { #{branch[0]} }" end "[#{content}, #{branch[1].inspect}]" end.join(', ') "lambda { |target, context, id| IfBinding.new(target, context, id, [#{branches}]) }" end |