Sha256: 42f9585a6da1ea7192293968ab47f17a411cbad2eb4251a171103263576760d9

Contents?: true

Size: 569 Bytes

Versions: 2

Compression:

Stored size: 569 Bytes

Contents

module Delorean
  module Model
    def self.included(base)
      base.send :extend, ClassMethods
    end

    module ClassMethods
      def delorean_fn(name, options = {}, &block)
        define_singleton_method(name) do |*args|
          block.call(*args)
        end

        sig = options[:sig]

        raise "no signature" unless sig

        if sig
          sig = [sig, sig] if sig.is_a? Fixnum
          raise "Bad signature" unless (sig.is_a? Array and sig.length==2)
          self.const_set(name.to_s.upcase+SIG, sig)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
delorean_lang-0.0.34 lib/delorean/model.rb
delorean_lang-0.0.33 lib/delorean/model.rb