Sha256: 0096940b08d3ff13626aa97a10680b45cd65246da6f28c6b8f2203413acb4857
Contents?: true
Size: 925 Bytes
Versions: 15
Compression:
Stored size: 925 Bytes
Contents
# frozen_string_literal: true module PriceHubble module EntityConcern module Attributes # A separated range typed attribute helper. module Range extend ActiveSupport::Concern class_methods do # Register a range attribute. # # @param name [Symbol, String] the name of the attribute # @param _args [Hash{Symbol => Mixed}] additional options 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 end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems