module Lolita::Builder

Any Lolita::Configuration class that should return visual information about itself can include Builder::Base, that provide default methods for controllers to use.

Usage in your model You can change behaviour of any of configuraton elements, to do so you should specify what builder you want to use.

lolita do
  list do
    column do
      name :my_column
      builder :name => "my_columns",:state => :display, :if=>{:state => :display}
    end
  end
end

This expample show, how to replace :display component of column by your own :display. :if is determine, that column use builder provided to component render, but when state is :display then it will be replaced with this on. There are elements, that only have one :display state, than it's not necessary to provide :if or :unless state.

Public Instance Methods

build(*values) click to toggle source
# File lib/lolita/builder.rb, line 218
def build *values
  result = builder.with(*values).build
  result[result.size-1].merge!(builder_default_options)
  result
end
builder(*args) click to toggle source
# File lib/lolita/builder.rb, line 205
def builder *args
  if args && args.any?
    set_builder(*args)
  else
    @builder||=set_builder(nil)
    @builder
  end
end
builder=(*args) click to toggle source
# File lib/lolita/builder.rb, line 214
def builder=(*args)
  set_builder(*args)
end
builder_default_name() click to toggle source
# File lib/lolita/builder.rb, line 228
def builder_default_name
  self.class.to_s.split("::").map(&:underscore).join("/").to_sym
end
Also aliased as: builder_name
builder_default_options() click to toggle source
# File lib/lolita/builder.rb, line 224
def builder_default_options
  {builder_local_variable_name => self}
end
builder_default_state() click to toggle source
# File lib/lolita/builder.rb, line 234
def builder_default_state
  :display
end
Also aliased as: default_build_state
builder_name()
default_build_state()

Private Instance Methods

builder_local_variable_name() click to toggle source
# File lib/lolita/builder.rb, line 246
def builder_local_variable_name 
  self.class.to_s.split("::").last.underscore.to_sym
end
set_builder(*args) click to toggle source
# File lib/lolita/builder.rb, line 242
def set_builder *args
  @builder=Lolita::Builder::Custom.create(self,*args)
end