Sha256: 69e9811162db08797f289dd07e56cfef49ee488ca945ea9a9eda1eb5eb08ad17

Contents?: true

Size: 713 Bytes

Versions: 9

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

module Quby
  module Questionnaires
    module DSL
      module CallsCustomMethods
        attr_reader :custom_methods

        def initialize(*args)
          options = args.last.is_a?(::Hash) ? args.last : {}
          @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

9 entries across 9 versions & 1 rubygems

Version Path
quby-4.0.4 lib/quby/questionnaires/dsl/calls_custom_methods.rb
quby-4.0.3 lib/quby/questionnaires/dsl/calls_custom_methods.rb
quby-4.0.2 lib/quby/questionnaires/dsl/calls_custom_methods.rb
quby-4.0.1 lib/quby/questionnaires/dsl/calls_custom_methods.rb
quby-4.0.0 lib/quby/questionnaires/dsl/calls_custom_methods.rb
quby-3.2.2 lib/quby/questionnaires/dsl/calls_custom_methods.rb
quby-3.2.1 lib/quby/questionnaires/dsl/calls_custom_methods.rb
quby-3.2.0 lib/quby/questionnaires/dsl/calls_custom_methods.rb
quby-3.2.0.pre.pre1 lib/quby/questionnaires/dsl/calls_custom_methods.rb