Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class.clone yields NoMethodError #69

Open
pmn4 opened this issue Jan 6, 2016 · 3 comments
Open

Class.clone yields NoMethodError #69

pmn4 opened this issue Jan 6, 2016 · 3 comments

Comments

@pmn4
Copy link

pmn4 commented Jan 6, 2016

Hey @thetron, I have some code which clones a class, but for token classes I get an error.

Repro steps:

require 'mongoid'
require 'mongoid_token'

class Person
  include Mongoid::Document
  include Mongoid::Token

  field :name

  token
end

Person.clone

this line yields a NoMethodError.

I can't tell whether self.token = nil is a relic of a previous implementation or I just am missing something. As a work-around, I have added def self.token=(*); end to classes which include mongoid_token, but want to make sure I'm not setting myself up for some headaches down the road.

Thanks!

thetron added a commit that referenced this issue Jan 7, 2016
@thetron
Copy link
Owner

thetron commented Jan 7, 2016

@pmn4 wow, good catch! the initialize_copyoverride was inadvertently a class method, which I've now moved out. I guess no one has tried doing that before 😄

Do you think you could try bundling with the commit referenced above and see if that sorts it out for you?

@pmn4
Copy link
Author

pmn4 commented Jan 7, 2016

That works! thanks @thetron

(admittedly, I did not test the cloning of instances, just classes)

@thetron
Copy link
Owner

thetron commented Jan 7, 2016

@pmn4 awesome! Thanks for testing - the instance cloning is/was covered by specs, so we're all good there!

williamatodd added a commit to williamatodd/mongoid_token that referenced this issue Apr 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants