Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ruby on Rails plugin designed to control ActiveRecord::Base to_xml and to_json methods output
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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