Module: ActiveGraph::Shared::TypecastedAttributes::ClassMethods

Defined in:
lib/active_graph/shared/typecasted_attributes.rb

Instance Method Summary collapse

Instance Method Details

#_attribute_type(attribute_name) ⇒ Object

Calculates an attribute type



90
91
92
# File 'lib/active_graph/shared/typecasted_attributes.rb', line 90

def _attribute_type(attribute_name)
  attributes[attribute_name].type || Object
end

#inspectString

Returns the class name plus its attribute names and types

Examples:

Inspect the model’s definition.

Person.inspect

Returns:

  • (String)

    Human-readable presentation of the attributes



81
82
83
84
85
# File 'lib/active_graph/shared/typecasted_attributes.rb', line 81

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

#typecast_attribute(typecaster, value) ⇒ Object



94
95
96
# File 'lib/active_graph/shared/typecasted_attributes.rb', line 94

def typecast_attribute(typecaster, value)
  ActiveGraph::Shared::TypeConverters.typecast_attribute(typecaster, value)
end