Module: ExposableAttributes::ClassMethods
- Defined in:
- lib/exposable_attributes.rb
Instance Method Summary collapse
-
#exposable_attributes(*attributes) ⇒ Object
Defines exposable attributes for AR object.
Instance Method Details
#exposable_attributes(*attributes) ⇒ Object
Defines exposable attributes for AR object.
Examples
class User < ActiveRecord::Base
exposable_attributes :json, :only => [:id, :login]
exposable_attributes :xml, :except => [:encrypted_password, :salt, :single_access_token]
exposable_attributes :json, :xml, :except => [:encrypted_password, :salt, :single_access_token]
end
20 21 22 23 24 25 |
# File 'lib/exposable_attributes.rb', line 20 def exposable_attributes(*attributes) init_default_accessors unless already_initialized? access_methods, = parse_attributes(attributes) access_methods.each {|method_name| define_accessor(method_name, ) } send :include, InstanceMethods end |