Class: ActiveModel::Type::Helpers::AcceptsMultiparameterTime
- Inherits:
-
Module
- Object
- Module
- ActiveModel::Type::Helpers::AcceptsMultiparameterTime
- Defined in:
- lib/active_model/type/helpers/accepts_multiparameter_time.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
-
#initialize(defaults: {}) ⇒ AcceptsMultiparameterTime
constructor
A new instance of AcceptsMultiparameterTime.
Constructor Details
#initialize(defaults: {}) ⇒ AcceptsMultiparameterTime
Returns a new instance of AcceptsMultiparameterTime.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_model/type/helpers/accepts_multiparameter_time.rb', line 37 def initialize(defaults: {}) include InstanceMethods define_method(:value_from_multiparameter_assignment) do |values_hash| defaults.each do |k, v| values_hash[k] ||= v end return unless values_hash[1] && values_hash[2] && values_hash[3] values = values_hash.sort.map!(&:last) ::Time.public_send(default_timezone, *values) end private :value_from_multiparameter_assignment end |