module ActiveAttr::TypecastedAttributes::ClassMethods

Public Instance Methods

_attribute_type(attribute_name) click to toggle source

Calculates an attribute type

@private @since 0.5.0

# File lib/active_attr/typecasted_attributes.rb, line 98
def _attribute_type(attribute_name)
  attributes[attribute_name][:type] || Object
end
inspect() click to toggle source

Returns the class name plus its attribute names and types

@example Inspect the model's definition.

Person.inspect

@return [String] Human-readable presentation of the attributes

@since 0.5.0

# File lib/active_attr/typecasted_attributes.rb, line 88
def inspect
  inspected_attributes = attribute_names.sort.map { |name| "#{name}: #{_attribute_type(name)}" }
  attributes_list = "(#{inspected_attributes.join(", ")})" unless inspected_attributes.empty?
  "#{name}#{attributes_list}"
end