Module: PriceHubble::EntityConcern::Attributes::Range
- Extended by:
- ActiveSupport::Concern
- Included in:
- PriceHubble::EntityConcern::Attributes
- Defined in:
- lib/price_hubble/entity/concern/attributes/range.rb
Overview
A separated range typed attribute helper.
Class Method Summary collapse
-
.typed_attr_range(name, **_args) ⇒ Object
Register a range attribute.
Class Method Details
.typed_attr_range(name, **_args) ⇒ Object
Register a range attribute.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/price_hubble/entity/concern/attributes/range.rb', line 15 def typed_attr_range(name, **_args) class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} # We cannot handle nil values return unless @#{name} # Otherwise we assume the hash contains a +lower+ and +upper+ # key from which we assemble the range hash = @#{name} hash[:lower]..hash[:upper] end RUBY end |