Sha256: 127a80b5492ab6f67d929bcf4cf1d1d7fc62be8540155d5425d5af9575a2f4a5

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

require 'paramix'

describe "dynamic methods using paramtric mixins" do

  module M
    include Paramix::Parametric

    parameterized do |params|

      public :f do
        params[:p]
      end

      attr_accessor params[:p]
    end
  end

  class C1
    include M[:p => "c1"]
  end

  class C2
    include M[:p => "c2"]
  end

  it "should" do
    c = C1.new
    c.f.should == "c1"
  end

  it "should" do
    c = C2.new
    c.f.should == "c2"
  end

  it "should" do
    c = C1.new
    c.c1 = :yes1
    c.c1.should == :yes1
  end

  it "should" do
    c = C2.new
    c.c2 = :yes2
    c.c2.should == :yes2
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paramix-2.0.1 spec/paramix_dynamic_spec.rb