module Caprese::Record::Aliasing::ClassMethods
Public Instance Methods
caprese_alias_field(field)
click to toggle source
Given an actual field, convert to its appropriate field alias for the class @note The reason this is useful is because ActiveRecord validations must validate the actual field name of a
model, but when we add errors they should always have aliased fields
@param [String,Symbol] field the actual field name to alias @return [Symbol] the aliased field name, or the original name symbolized
# File lib/caprese/record/aliasing.rb, line 30 def caprese_alias_field(field) caprese_field_aliases.invert[field = field.to_sym] || field end
caprese_field_aliases()
click to toggle source
Provides the ability to display an aliased field name to the consumer of the API, and then map that name to its real name on the server @example
{ alias: :actual }
# File lib/caprese/record/aliasing.rb, line 48 def caprese_field_aliases {} end
caprese_type()
click to toggle source
The type that is serialized and responded with for this class
# File lib/caprese/record/aliasing.rb, line 53 def caprese_type self.name.underscore end
caprese_unalias_field(field)
click to toggle source
Given an aliased field, convert to its actual field for the class
@param [String,Symbol] field the actual field name to alias @return [Symbol] the aliased field name, or the original name symbolized
# File lib/caprese/record/aliasing.rb, line 38 def caprese_unalias_field(field) caprese_field_aliases[field = field.to_sym] || field end