Class: Neighbor::NormalizedAttribute

Inherits:
ActiveRecord::Type::Value
  • Object
show all
Defined in:
lib/neighbor/normalized_attribute.rb

Instance Method Summary collapse

Constructor Details

#initialize(cast_type:, model:, attribute_name:) ⇒ NormalizedAttribute

Returns a new instance of NormalizedAttribute.



5
6
7
8
9
# File 'lib/neighbor/normalized_attribute.rb', line 5

def initialize(cast_type:, model:, attribute_name:)
  @cast_type = cast_type
  @model = model
  @attribute_name = attribute_name.to_s
end

Instance Method Details

#castObject



11
12
13
# File 'lib/neighbor/normalized_attribute.rb', line 11

def cast(...)
  Neighbor::Utils.normalize(@cast_type.cast(...), column_info: @model.columns_hash[@attribute_name])
end