Sha256: d6b5eca5a1cf60895b53e8f8aac85f9f07bf22e48833e4432b43f25c36cc2fdb

Contents?: true

Size: 502 Bytes

Versions: 2

Compression:

Stored size: 502 Bytes

Contents

# OpenDSL is a clever way to create a plugable
# free-form domain specific language.
#
#   Example = OpenDSL.new do
#     size do
#       100
#     end
#   end
#
#   class Foo
#     include Example
#   end
#
#   Foo.new.size  #=> 100
#
class OpenDSL < Module

  require 'opendsl/version'

  #
  def initialize(&block)
    instance_eval(&block) if block_given?
  end

  #
  def method_missing(s, *a, &b)
    if block_given?
      define_method(s, &b)
    else
      super(s, *a, &b)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opendsl-1.1.1 lib/opendsl.rb
opendsl-1.1.0 lib/opendsl.rb