Module: PriceHubble::EntityConcern::Attributes::DateArray

Extended by:
ActiveSupport::Concern
Included in:
PriceHubble::EntityConcern::Attributes
Defined in:
lib/price_hubble/entity/concern/attributes/date_array.rb

Overview

A separated date array typed attribute helper.

Class Method Summary collapse

Class Method Details

.typed_attr_date_array(name, **_args) ⇒ Object

Register a date array attribute (only sanitization).

Parameters:

  • name (Symbol, String)

    the name of the attribute

  • _args (Hash{Symbol => Mixed})

    additional options



15
16
17
18
19
20
21
22
23
24
# File 'lib/price_hubble/entity/concern/attributes/date_array.rb', line 15

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