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

Additional syntax #1

Open
martinciu opened this issue Jun 14, 2015 · 1 comment
Open

Additional syntax #1

martinciu opened this issue Jun 14, 2015 · 1 comment

Comments

@martinciu
Copy link

What do you think about adding the following syntax:

class Person
  include Lift.new(:name, :email)

end
@nilbus
Copy link

nilbus commented Aug 4, 2015

If you decide to do this, the equalizer gem has an example implementation.

An implementation might look like this (untested):

class Lift < Module
  module Initializer
    # original Lift implementation
  end

  def initialize(*attributes)
    @attributes = attributes
  end

  def included(descendant)
    super
    attributes = @attributes
    descendant.module_eval do
      include Lift::Initializer
      attr_accessor *attributes
    end
  end
end

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

No branches or pull requests

2 participants