Paramix

Discussion in 'Ruby' started by Trans, Apr 5, 2008.

  1. Trans

    Trans Guest

    I've just finished restoring paramix.rb to Facets library. You can
    expect it in 2.4.2 which I will release soon. (Note that the version
    included in 2.4.1 is a work in progress and should not be used).

    Just to let people know how it works now, as opposed to the old
    version which overrode #include itself, the new version uses a
    delegating module. So it is much more robust.

    Here is a simple example:

    require 'facets/paramix'

    module MyMixin
    include Paramix

    def hello
    puts "Hello from #{mixin_params[MyMixin][:name]}!"
    end
    end

    class MyClass
    include Mixin[:name => 'Ruby']
    end

    m = MyClass.new
    m.hello -> 'Hello from Ruby!'

    Notice the use of #[]. Capitalized methods have namespace issues, so
    the #[] method was used instead.

    T.
    Trans, Apr 5, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacob Burkhart

    Suggest alternatives for Facets paramix?

    Jacob Burkhart, Mar 31, 2008, in forum: Ruby
    Replies:
    5
    Views:
    82
    Trans
    Apr 7, 2008
Loading...

Share This Page