Class: ActiveModel::Type::Helpers::AcceptsMultiparameterTime

Inherits:
Module
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/helpers/accepts_multiparameter_time.rb

Defined Under Namespace

Modules: InstanceMethods

Constant Summary

Constants inherited from Module

Module::DELEGATION_RESERVED_KEYWORDS, Module::DELEGATION_RESERVED_METHOD_NAMES, Module::RUBY_RESERVED_KEYWORDS

Instance Method Summary collapse

Methods inherited from Module

#alias_attribute, #anonymous?, #append_features, #as_json, #attr_internal_accessor, #attr_internal_reader, #attr_internal_writer, #blankslate_original_append_features, #delegate, #delegate_missing_to, #deprecate, #infect_an_assertion, #mattr_accessor, #mattr_reader, #mattr_writer, #method_visibility, #module_parent, #module_parent_name, #module_parents, #rake_extension, #redefine_method, #redefine_singleton_method, #remove_possible_method, #remove_possible_singleton_method, #silence_redefinition_of_method, #thread_mattr_accessor, #thread_mattr_reader, #thread_mattr_writer

Methods included from Module::Concerning

#concern, #concerning

Constructor Details

#initialize(defaults: {}) ⇒ AcceptsMultiparameterTime

Returns a new instance of AcceptsMultiparameterTime.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/helpers/accepts_multiparameter_time.rb', line 33

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