Class: ActionSet::Instruction::Value::TimeWithZoneAdapter

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

Instance Method Summary collapse

Constructor Details

#initialize(raw, target) ⇒ TimeWithZoneAdapter

Returns a new instance of TimeWithZoneAdapter.



137
138
139
140
# File 'lib/action_set/instruction/value.rb', line 137

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

Instance Method Details

#processObject



142
143
144
145
146
147
148
149
150
# File 'lib/action_set/instruction/value.rb', line 142

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