Sha256: 0677e31cf7ed59437dd94600461cb92b8ba747d6622a00710af7279a87610176

Contents?: true

Size: 605 Bytes

Versions: 35

Compression:

Stored size: 605 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? Fixnum
          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

35 entries across 35 versions & 1 rubygems

Version Path
delorean_lang-0.2.1 lib/delorean/model.rb
delorean_lang-0.2.0 lib/delorean/model.rb
delorean_lang-0.1.7 lib/delorean/model.rb
delorean_lang-0.1.6 lib/delorean/model.rb
delorean_lang-0.1.5 lib/delorean/model.rb
delorean_lang-0.1.04 lib/delorean/model.rb
delorean_lang-0.1.03 lib/delorean/model.rb
delorean_lang-0.1.02 lib/delorean/model.rb
delorean_lang-0.1.01 lib/delorean/model.rb
delorean_lang-0.1.00 lib/delorean/model.rb
delorean_lang-0.0.43 lib/delorean/model.rb
delorean_lang-0.0.42 lib/delorean/model.rb
delorean_lang-0.0.40 lib/delorean/model.rb
delorean_lang-0.0.39 lib/delorean/model.rb
delorean_lang-0.0.38 lib/delorean/model.rb