Module: PriceHubble::EntityConcern::Attributes::StringInquirer

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

Overview

A separated string inquirer typed attribute helper.

Class Method Summary collapse

Class Method Details

.typed_attr_string_inquirer(name, **_args) ⇒ Object

Register a casted string inquirer attribute.

Parameters:

  • name (Symbol, String)

    the name of the attribute

  • _args (Hash{Symbol => Mixed})

    additional options



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

def typed_attr_string_inquirer(name, **_args)
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
    def #{name}=(value)
      #{name}_will_change!
      @#{name} = ActiveSupport::StringInquirer.new(value.to_s)
    end
  RUBY
end