Module: SerializeAttributes

Extended by:
ActiveSupport::Concern
Defined in:
lib/serialize_attributes.rb,
lib/serialize_attributes/store.rb,
lib/serialize_attributes/version.rb,
lib/serialize_attributes/types/enum.rb

Overview

Serialize ActiveModel attributes in JSON using type casting

Defined Under Namespace

Modules: Types Classes: Store

Constant Summary collapse

VERSION =
"1.0.1"

Instance Method Summary collapse

Instance Method Details

#serialized_attributes_on(column_name) ⇒ Object

Retrieve all of the SerializeAttributes attributes, including their default values

person = Person.new
person.serialized_attributes_on(:settings)
#=> { "user_name" => "Christian" }


50
51
52
53
54
55
56
# File 'lib/serialize_attributes.rb', line 50

def serialized_attributes_on(column_name)
  store = self.class.serialized_attributes_store(column_name)

  store.attribute_names.index_with do |attribute_name|
    public_send(attribute_name)
  end
end