Module: Extjsizable::CoreExt::Array::ExtJs::InstanceMethods
- Defined in:
- lib/extjsizable/core_ext/array/extjs.rb
Instance Method Summary collapse
-
#to_extjs(options = {}) ⇒ Object
Creates a JSON object by specifying which attributes we want to be shown.
Instance Method Details
#to_extjs(options = {}) ⇒ Object
Creates a JSON object by specifying which attributes we want to be shown. Ej: { ‘total’ : 2,
'data' : [
{ 'id' : 1, :nombre : 'Juan' },
{ 'id' : 2, :nombre : 'Pedro' }
]
}
24 25 26 27 28 29 30 31 32 |
# File 'lib/extjsizable/core_ext/array/extjs.rb', line 24 def to_extjs( = {}) array_json_data = as_json() if ::Array.dasherize_keys? array_json_data.map! { |h| dasherize_hash_keys(h) } end { :total => (.delete(:total) || self.length), :data => array_json_data }.with_indifferent_access end |