module PublicAttributes::ClassMethods

Public Instance Methods

public_attributes(*attr_list) click to toggle source
# File lib/public_attributes.rb, line 31
def public_attributes(*attr_list)
  PublicAttributes.add(name, attr_list)
end
to_public() click to toggle source
# File lib/public_attributes.rb, line 35
def to_public
  if defined?(ActiveRecord) && (self < ActiveRecord::Base)
    where(nil).map do |instance|
      instance.to_public
    end
  else
    raise Error 'This method is only available for ActiveRecord classes. '\
                'Please re-implement if you\'d like to call to_public on '\
                'a custom collection.'
  end
end