Sha256: 6b0c5f71fff53869acd8646f9759f7e13d7df4c8b2fc1f36f0a470c3d4586264
Contents?: true
Size: 754 Bytes
Versions: 5
Compression:
Stored size: 754 Bytes
Contents
gem 'dry-types', '>= 1.0.0' require "dry-types" module Representable module Coercion module Types include Dry::Types() end class Coercer def initialize(type) @type = type end def call(input, _options) @type.call(input) end end def self.included(base) base.class_eval do extend ClassMethods register_feature Coercion end end module ClassMethods def property(name, options={}, &block) super.tap do |definition| return definition unless type = options[:type] definition.merge!(render_filter: coercer = Coercer.new(type)) definition.merge!(parse_filter: coercer) end end end end end
Version data entries
5 entries across 5 versions & 3 rubygems