Sha256: 65737523c4f07856f138575b0c242edfeea3735cd03de52872c6d5b9fb64ea7b

Contents?: true

Size: 657 Bytes

Versions: 24

Compression:

Stored size: 657 Bytes

Contents

# frozen_string_literal: true

module Quby
  module Compiler
    module DSL
      module CallsCustomMethods
        attr_reader :custom_methods

        def initialize(*args, **options)
          @custom_methods = options[:custom_methods] || {}
          super
        end

        def method_missing(method_sym, *args, &block)
          if @custom_methods.key? method_sym
            instance_exec(*args, &custom_methods[method_sym])
          else
            super
          end
        end

        def respond_to_missing?(method_name, include_private = false)
          custom_methods.key?(method_name) || super
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
quby-compiler-0.3.6 lib/quby/compiler/dsl/calls_custom_methods.rb
quby-compiler-0.3.5 lib/quby/compiler/dsl/calls_custom_methods.rb
quby-compiler-0.3.4 lib/quby/compiler/dsl/calls_custom_methods.rb
quby-compiler-0.3.3 lib/quby/compiler/dsl/calls_custom_methods.rb