Sha256: 6b361f1b55049baf53a2f1b8fd453e5581e352168b0030ce08e93e68cc0768b0

Contents?: true

Size: 606 Bytes

Versions: 5

Compression:

Stored size: 606 Bytes

Contents

require 'delorean/const'

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? Integer
          raise "Bad signature" unless (sig.is_a? Array and sig.length==2)
          self.const_set(name.to_s.upcase+Delorean::SIG, sig)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
delorean_lang-0.4.6 lib/delorean/model.rb
delorean_lang-0.4.5 lib/delorean/model.rb
delorean_lang-0.4.4 lib/delorean/model.rb
delorean_lang-0.4.2 lib/delorean/model.rb
delorean_lang-0.4.1 lib/delorean/model.rb