Module: Sequel::Plugins::ExtJS::InstanceMethods

Defined in:
lib/sequel_extjs.rb

Instance Method Summary collapse

Instance Method Details

#to_extjsObject

Same as the dataset method, but it only works for single records (including ones that are not saved yet)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/sequel_extjs.rb', line 46

def to_extjs()
  data = self
  if block_given?
    data = yield self
  end
  fields = data.keys.map{|a| {:name => a}}

  {
    :totalCount => 1,
    :metaData => {
      :totalProperty => 'totalCount',
      :root => 'result',
      :id => primary_key,
      :fields => fields
    },
    :result => [data]
  }.to_json
end

#to_json(*a) ⇒ Object

return a json hash from the current Model instance, this will work even on joins and it will include all selected fields



41
42
43
# File 'lib/sequel_extjs.rb', line 41

def to_json(*a)
 values.to_json(*a)
end