Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

getters should use default values even if model was not properly initialized #13

Closed
JelF opened this issue Oct 26, 2016 · 0 comments
Closed

Comments

@JelF
Copy link

JelF commented Oct 26, 2016

steps to reproduce:

  Foo = Class.new
  Foo.include(Tainbox)
  dumped = Foo.new.to_yaml # => "--- !ruby/object:Foo {}\n"
  Foo.send(:attribute, :bar, default: :baz)

expected result

  YAML.load(dumped).bar # => :baz

actual result

  YAML.load(dumped).bar # => nil

possible workaround

def bar
  attribute_provided?(:bar) ? super : tainbox_set_default_bar
end
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants