Module: Lolita::Builder
- Included in:
- Configuration::Action, Configuration::Base, Configuration::Columns, Configuration::Field::Base, Configuration::Filter, Configuration::List, Configuration::NestedForm, Configuration::Search, Configuration::Tab::Base
- Defined in:
- lib/lolita/builder.rb
Overview
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 for Lolita::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.
Defined Under Namespace
Classes: Custom
Instance Method Summary collapse
- #build(*values) ⇒ Object
- #builder(*args) ⇒ Object
- #builder=(*args) ⇒ Object
- #builder_default_name ⇒ Object (also: #builder_name)
- #builder_default_options ⇒ Object
- #builder_default_state ⇒ Object (also: #default_build_state)
Instance Method Details
#build(*values) ⇒ Object
218 219 220 221 222 |
# File 'lib/lolita/builder.rb', line 218 def build *values result = builder.with(*values).build result[result.size-1].merge!() result end |
#builder(*args) ⇒ Object
205 206 207 208 209 210 211 212 |
# 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) ⇒ Object
214 215 216 |
# File 'lib/lolita/builder.rb', line 214 def builder=(*args) set_builder(*args) end |
#builder_default_name ⇒ Object Also known as: builder_name
228 229 230 |
# File 'lib/lolita/builder.rb', line 228 def builder_default_name self.class.to_s.split("::").map(&:underscore).join("/").to_sym end |
#builder_default_options ⇒ Object
224 225 226 |
# File 'lib/lolita/builder.rb', line 224 def {builder_local_variable_name => self} end |
#builder_default_state ⇒ Object Also known as: default_build_state
234 235 236 |
# File 'lib/lolita/builder.rb', line 234 def builder_default_state :display end |