Sha256: 5a967872bbee8fad75b5a2cbaa2f769bc3b11378aa52b199a8739e7c110f6f37

Contents?: true

Size: 827 Bytes

Versions: 15

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true

module PriceHubble
  module EntityConcern
    module Attributes
      # A separated date array typed attribute helper.
      module DateArray
        extend ActiveSupport::Concern

        class_methods do
          # Register a date array attribute (only sanitization).
          #
          # @param name [Symbol, String] the name of the attribute
          # @param _args [Hash{Symbol => Mixed}] additional options
          def typed_attr_date_array(name, **_args)
            class_eval <<-RUBY, __FILE__, __LINE__ + 1
              def sanitize_attr_#{name}
                return if @#{name}.nil?
                @#{name}.map do |date|
                  date.strftime('%Y-%m-%d')
                end
              end
            RUBY
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pricehubble-1.3.0 lib/price_hubble/entity/concern/attributes/date_array.rb
pricehubble-1.2.5 lib/price_hubble/entity/concern/attributes/date_array.rb
pricehubble-1.2.4 lib/price_hubble/entity/concern/attributes/date_array.rb
pricehubble-1.2.3 lib/price_hubble/entity/concern/attributes/date_array.rb
pricehubble-1.2.2 lib/price_hubble/entity/concern/attributes/date_array.rb
pricehubble-1.2.1 lib/price_hubble/entity/concern/attributes/date_array.rb
pricehubble-1.2.0 lib/price_hubble/entity/concern/attributes/date_array.rb
pricehubble-1.1.0 lib/pricehubble/entity/concern/attributes/date_array.rb
pricehubble-1.0.0 lib/pricehubble/entity/concern/attributes/date_array.rb
pricehubble-0.4.2 lib/pricehubble/entity/concern/attributes/date_array.rb
pricehubble-0.4.1 lib/pricehubble/entity/concern/attributes/date_array.rb
pricehubble-0.4.0 lib/pricehubble/entity/concern/attributes/date_array.rb
pricehubble-0.3.0 lib/pricehubble/entity/concern/attributes/date_array.rb
pricehubble-0.2.0 lib/pricehubble/entity/concern/attributes/date_array.rb
pricehubble-0.1.0 lib/pricehubble/entity/concern/attributes/date_array.rb