Sha256: 1ee4325620b0877cd7986af1992fca42fa919b265435698ce5422432680b7ee8

Contents?: true

Size: 443 Bytes

Versions: 9

Compression:

Stored size: 443 Bytes

Contents

require "active_model"

class Customer < Struct.new(:name, :id)
  extend ActiveModel::Naming
  include ActiveModel::Conversion

  undef_method :to_json

  def to_xml(options={})
    if options[:builder]
      options[:builder].name name
    else
      "<name>#{name}</name>"
    end
  end

  def to_js(options={})
    "name: #{name.inspect}"
  end
  alias :to_text :to_js

  def errors
    []
  end

  def persisted?
    id.present?
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
prototype-rails-4.0.0 test/lib/controller/fake_models.rb
prototype-rails-3.2.1 test/lib/controller/fake_models.rb
prototype-rails-3.2.0.rc1 test/lib/controller/fake_models.rb
prototype-rails-3.2.0 test/lib/controller/fake_models.rb
prototype-rails-3.1.0 test/lib/controller/fake_models.rb
prototype-rails-0.3.1 test/lib/controller/fake_models.rb
prototype-rails-0.3.0 test/lib/controller/fake_models.rb
prototype-rails-0.2 test/lib/controller/fake_models.rb
prototype-rails-0.1 test/lib/controller/fake_models.rb