Sha256: 19c367a1d9f5ba8b9eb9eecb9e585c8383e8327872d487197ef3f9e1d766ec7a
Contents?: true
Size: 896 Bytes
Versions: 22
Compression:
Stored size: 896 Bytes
Contents
module Spina module AttrJsonMonkeypatch extend ActiveSupport::Concern included do |base| extend ClassMethods end module ClassMethods def attr_json_setter_monkeypatch(name) # Ruby bug in 3.0.0 related to defined?(super) returning true # https://github.com/jrochkind/attr_json/issues/112 if RUBY_VERSION == "3.0.0" && RUBY_PATCHLEVEL == 0 define_method("#{name}=") do |value| # This next line is uncommented in the attr_json gem # We don't care about super here, so let's just comment it for now # super(value) if defined?(super) attribute_def = self.class.attr_json_registry.fetch(name.to_sym) public_send(attribute_def.container_attribute)[attribute_def.store_key] = attribute_def.cast(value) end end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems