Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby on Rails plugin
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
rails
tasks
test
.gitignore
MIT-LICENSE
README.rdoc
Rakefile
exposable_attributes.gemspec
install.rb
uninstall.rb

README.rdoc

exposable_attributes

Exposable Attributes plugin is designed to control ActiveRecord::Base to_xml and to_json methods output. It might be useful with plugins like inherited_resources.

Resources

Source

  • git://github.com/nikolaeff/exposable_attributes

Example

Redefine to_xml() and to_json() with def params as :only => [:id, :login, :password]

class User < ActiveRecord::Base
  exposable_attributes :id, :login, :password
end

Redefine to_json method only, to_xml will be defined as usual

class User < ActiveRecord::Base
  exposable_attributes :json, :only => [:id, :login]
end

Redefine to_xml only with “except” statement

class User < ActiveRecord::Base
  exposable_attributes :xml,  :except => [:encrypted_password, :salt, :single_access_token]
end

Redefine both to_xml and to_json

class User < ActiveRecord::Base
  exposable_attributes :json, :xml, :except => [:encrypted_password, :salt, :single_access_token]
end

Copyright © 2010 nikolaeff, released under the MIT license

Something went wrong with that request. Please try again.