Class: ActionSet::AttributeValue::TimeWithZoneAdapter

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

Instance Method Summary collapse

Constructor Details

#initialize(raw, target) ⇒ TimeWithZoneAdapter

Returns a new instance of TimeWithZoneAdapter.



145
146
147
148
# File 'lib/action_set/attribute_value.rb', line 145

def initialize(raw, target)
  @raw = raw
  @target = target
end

Instance Method Details

#processObject



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/action_set/attribute_value.rb', line 150

def process
  return if @raw.is_a? @target
  return unless @target.eql?(ActiveSupport::TimeWithZone)

  time_value = ActiveModelAdapter.new(@raw, Time).process

  return unless time_value.is_a?(Time)
  return time_value unless time_value.respond_to?(:in_time_zone)

  time_value.in_time_zone
end