Skip to content

Allow overriding column setter #226

@mloughran

Description

@mloughran

Apologies if this is possible and I've overlooked.

I'm struggling to understand why the custom Account#email= method in the following does not get called:

require "spec"
require "clear"

class Account
  include Clear::Model

  column email : String

  def email=(e : String)
    super(email.downcase.strip)
  end
end

describe Account do
  it "overrides email setter" do
    account = Account.new
    account.email = "FOO@example.com "
    account.email.should eq("foo@example.com")
  end
end

Is there a better way of achieving this? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions