Module: PriceHubble::Concern::Attributes::DateArray

Extended by:
ActiveSupport::Concern
Included in:
PriceHubble::Concern::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 "    def sanitize_attr_\#{name}\n      return if @\#{name}.nil?\n      @\#{name}.map do |date|\n        date.strftime('%Y-%m-%d')\n      end\n    end\n  RUBY\nend\n", __FILE__, __LINE__ + 1