Module: Lolita::Builder
- Included in:
- Configuration::Field::Base, Configuration::Filter, Configuration::List, Configuration::Tab::Base, Configuration::Tabs
- 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.
Instance Method Summary collapse
-
#build(*args) ⇒ Object
Build response.
-
#builder_options ⇒ Object
Default options for class.
-
#default_builder ⇒ Object
Return default builder information.
-
#get_builder(*value) ⇒ Object
Set or get builder for class.
Instance Method Details
#build(*args) ⇒ Object
Build response. Render component for current class with given options.
14 15 16 17 18 19 20 21 |
# File 'lib/lolita/builder.rb', line 14 def build(*args) args||=[] =args. =self. || {} =( || {}).merge() builder_values=self.get_builder(*args) return builder_values[:name].to_sym,builder_values[:state].to_sym, end |
#builder_options ⇒ Object
Default options for class. This method should be overwritten.
24 25 26 |
# File 'lib/lolita/builder.rb', line 24 def {builder_local_variable_name=>self} end |
#default_builder ⇒ Object
Return default builder information.
49 50 51 |
# File 'lib/lolita/builder.rb', line 49 def default_builder {:name=>"/#{builder_name}".to_sym,:state=>default_build_state} end |
#get_builder(*value) ⇒ Object
Set or get builder for class. Value can be
-
Hashwhere key:nameis component name and:stateis component state -
Array or two args- first is used as name and second as state. -
String or Symbol (one arg)- is used as name.
Default name is Lolita::Configuration class name (example :list) and default state is :display
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lolita/builder.rb', line 35 def get_builder(*value) if value && !value.empty? set_builder(value) elsif @builder set_builder(@builder) else unless @builder @builder=default_builder end @builder end end |