Class: Ext::Data::JsonReader

Inherits:
Base
  • Object
show all
Defined in:
lib/ext/data/json_reader.rb

Instance Method Summary collapse

Methods inherited from Base

#camelize_keys, ext_patch, #fixed_values, #initialize, #option, to_json, #to_json, #to_s

Constructor Details

This class inherits a constructor from Ext::Base

Instance Method Details

#argsObject



12
13
14
# File 'lib/ext/data/json_reader.rb', line 12

def args
  [options, columns]
end

#columnsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ext/data/json_reader.rb', line 16

def columns
  cols = []
  cols += guess_columns(klass) if klass

  case @options[:columns]
  when NilClass               # nop
  when Array
    cols += @options[:columns]
  else
    raise ArgumentError, "Invalid format: %s for Array" % @options[:columns].class
  end
  return cols
end

#optionsObject



4
5
6
7
8
9
10
# File 'lib/ext/data/json_reader.rb', line 4

def options
  {
    :id            => @options[:id] || (klass && klass.primary_key) || 'id',
    :root          => @options[:root] || 'items',
    :totalProperty => @options[:total_property] || 'count',
  }
end