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.
-
build
method is used to render component for class instance. -
build_options is method that return specific options for builder, to pass to component, such as :color,:postition etc.
-
builder
is setter/getter method forLolita::Configuration
, that accept Hash or Array or single String or Symbol for buider.
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
# 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
# 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
# File lib/lolita/builder.rb, line 214 def builder=(*args) set_builder(*args) end
# File lib/lolita/builder.rb, line 228 def builder_default_name self.class.to_s.split("::").map(&:underscore).join("/").to_sym end
# File lib/lolita/builder.rb, line 224 def builder_default_options {builder_local_variable_name => self} end
# File lib/lolita/builder.rb, line 234 def builder_default_state :display end
Private Instance Methods
# File lib/lolita/builder.rb, line 246 def builder_local_variable_name self.class.to_s.split("::").last.underscore.to_sym end
# File lib/lolita/builder.rb, line 242 def set_builder *args @builder=Lolita::Builder::Custom.create(self,*args) end