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

Including a module after a call to attributes doesn't work #3

Open
louismrose opened this issue Apr 11, 2014 · 1 comment
Open

Including a module after a call to attributes doesn't work #3

louismrose opened this issue Apr 11, 2014 · 1 comment
Labels

Comments

@louismrose
Copy link
Member

As described in the example "should work when include is last" of specialisation_spec.rb, including a module after calling attributes results in unexpected behaviour:

module Author
    extend Attributable
    attributes articles: []
end

class Columnist
  extend Attributable
  attributes :column
  include Author
end

Columnist.new(articles: [:teen_advice])
# => KeyError: Unknown attributes: articles

When the include occurs before the call to attributes, the error disappears.

@louismrose louismrose added the bug label Apr 11, 2014
@louismrose
Copy link
Member Author

One approach that might fix both this issue and issue #2 could be to add the accessors, equality, etc. methods when the attributable class is initialized to create a new object, and not when the call to attributes is made.

@louismrose louismrose changed the title Included a module after a call to attributes doesn't work Including a module after a call to attributes doesn't work Apr 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant