Class: ActiveRecord::Serialization::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/serializable_data.rb

Instance Method Summary collapse

Instance Method Details

#serializable_attribute_names_with_serializable_dataObject Also known as: serializable_attribute_names



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/serializable_data.rb', line 6

def serializable_attribute_names_with_serializable_data
  attribute_names = serializable_attribute_names_without_serializable_data
  if @record.class.include?(SerializableData)
    attribute_names.delete(@record.class._data_column.to_s)
    only = Array.wrap(options[:only]).map(&:to_s)
    except = Array.wrap(options[:except]).map(&:to_s)
    serialized_data_attributes = @record.class._data_attributes.map(&:to_s)
    attribute_names |= if only.any?
                         serialized_data_attributes & only
                       elsif except.any?
                         serialized_data_attributes - except
                       end
  end
  attribute_names
end