Sha256: 7ca43dc4c2d346e54f3a7f35d2d62402fd007a56c839f27388b672ae4c46b34d

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

class Object
    # Throw a TypeError unless this object's type is cls
    #
    # @param cls The class this object should be
    def should_be_a(cls)
        raise(TypeError, "#{self.to_s} must be of type #{cls.to_s}") unless self.is_a?(cls)
    end
end

module Martin
    module DSL
        class Method
            attr_accessor :block
            def initialize(block)
                block.should_be_a(Proc)
                @block = block
            end
        end
        
        class Configure < Method; end
        class Command < Method
            attr_accessor :regexp
            def initialize(regexp, block)
                super(block)
                regexp.should_be_a(Regexp)
                @regexp = regexp
            end
        end
        class Error < Method; end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
martin-0.1.3 lib/martin/dsl.rb