diff --git a/README.md b/README.md index 216a333..5582f36 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,28 @@ class NullPlan def pro? = false def ent? = false end +``` +```ruby class Account belongs_to :plan, optional: true, null_object: NullPlan.instance end ``` +```ruby +account = Account.create + +puts account.plan # => # +puts account.plan.free? # => true +puts account.plan.ent? # => false + +account.update(plan: Plan.new(ent: true)) + +puts account.plan # => # +puts account.plan.free? # => false +puts account.plan.ent? # => true +``` + ## Supported Rubies **`null_association` supports Ruby 3.1 and above.** We encourage you to upgrade