Module: Spina::AttrJsonMonkeypatch::ClassMethods
- Defined in:
- lib/spina/attr_json_monkeypatch.rb
Instance Method Summary collapse
Instance Method Details
#attr_json_setter_monkeypatch(name) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/spina/attr_json_monkeypatch.rb', line 10 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 |