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.



151
152
153
154
# File 'lib/action_set/attribute_value.rb', line 151

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

Instance Method Details

#processObject



156
157
158
159
160
161
162
163
164
165
166
# File 'lib/action_set/attribute_value.rb', line 156

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