Module: DataMapper::ExtJS::Resource

Defined in:
lib/dm-extjs/resource.rb

Instance Method Summary collapse

Instance Method Details

#ext_errorsObject



15
16
17
# File 'lib/dm-extjs/resource.rb', line 15

def ext_errors
  respond_to?(:errors) ? errors.to_a : []
end

#to_extjs(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/dm-extjs/resource.rb', line 5

def to_extjs (options={})
  ret = {
    :metaData => self.class.ext_meta(options[:methods]),
    :success => options.has_key?(:success) ? options[:success] : (saved? && clean?),
    :message => (ext_errors << (options[:message] || '')).join("\n"),
    :results => self.to_json(options.merge(:to_json => false))
  }
  options.fetch(:to_json, true) ? ret.to_json : ret
end