Module: RailsJqGrid::JqGridMethodMissing
- Included in:
- JqGrid, JqGridColumn, JqGridNavGrid, JqGridNavGridParameter
- Defined in:
- app/models/rails_jq_grid/jq_grid_method_missing.rb
Overview
Method-Missing implementation converts unknown method to options and save it’s values
Instance Attribute Summary collapse
-
#jq_grid_js_options ⇒ Object
Returns the value of attribute jq_grid_js_options.
Instance Method Summary collapse
-
#get_jq_grid_js_options(symbol) ⇒ Object
returns the value of a option.
-
#init_jq_grid_js_options(new_options) ⇒ Object
initialize options with default values.
-
#method_missing(symbol, *args, &block) ⇒ Object
every unknown method is treated as a jqgrid option oder method name.
-
#options_to_jqgrid_options ⇒ Object
converts options to a string for jqgrid.
-
#raw(*args) ⇒ Object
Values market with raw are not convertet to_json they will be outputet as they are see JqGridOptionOrMethod.escaped_value.
- #set_jqgrid_options(&option_block) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
every unknown method is treated as a jqgrid option oder method name
21 22 23 24 25 |
# File 'app/models/rails_jq_grid/jq_grid_method_missing.rb', line 21 def method_missing(symbol, *args, &block) self. ||={} self.[symbol] = JqGridOptionOrMethod.new(symbol, args[0]) #end end |
Instance Attribute Details
#jq_grid_js_options ⇒ Object
Returns the value of attribute jq_grid_js_options.
17 18 19 |
# File 'app/models/rails_jq_grid/jq_grid_method_missing.rb', line 17 def end |
Instance Method Details
#get_jq_grid_js_options(symbol) ⇒ Object
returns the value of a option
34 35 36 |
# File 'app/models/rails_jq_grid/jq_grid_method_missing.rb', line 34 def (symbol) self.[symbol] end |
#init_jq_grid_js_options(new_options) ⇒ Object
initialize options with default values
39 40 41 42 43 44 |
# File 'app/models/rails_jq_grid/jq_grid_method_missing.rb', line 39 def () self. ||={} .each do |key, value| self.[key] = JqGridOptionOrMethod.new(key, value) end end |
#options_to_jqgrid_options ⇒ Object
converts options to a string for jqgrid
47 48 49 50 51 52 53 |
# File 'app/models/rails_jq_grid/jq_grid_method_missing.rb', line 47 def = [] self..each_value { |option| << "#{option.escaped_name}: #{option.escaped_value}" } .sort.join(",\n ") end |
#raw(*args) ⇒ Object
Values market with raw are not convertet to_json they will be outputet as they are see JqGridOptionOrMethod.escaped_value
29 30 31 |
# File 'app/models/rails_jq_grid/jq_grid_method_missing.rb', line 29 def raw(*args) {:type => :raw, :value => args[0]} end |
#set_jqgrid_options(&option_block) ⇒ Object
55 56 57 |
# File 'app/models/rails_jq_grid/jq_grid_method_missing.rb', line 55 def (&option_block) option_block.call(self) if block_given? end |