Class: Trenni::Builder::Fragment

Inherits:
Object
  • Object
show all
Defined in:
lib/trenni/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ Fragment

Returns a new instance of Fragment.



34
35
36
37
# File 'lib/trenni/builder.rb', line 34

def initialize(block)
  @block = block
  @builder = nil
end

Instance Method Details

#==(other) ⇒ Object



53
54
55
56
# File 'lib/trenni/builder.rb', line 53

def == other
  # This is a bit of a hack... but is required for existing specs to pass:
  self.to_s == other.to_s
end

#call(builder) ⇒ Object



39
40
41
# File 'lib/trenni/builder.rb', line 39

def call(builder)
  @block.call(builder)
end

#to_sObject



43
44
45
46
47
48
49
50
51
# File 'lib/trenni/builder.rb', line 43

def to_s
  unless @builder
    @builder = Builder.new
    
    self.call(@builder)
  end
  
  return @builder.to_s
end