Sha256: 20ddc94c35518c3b9dba76065ff97f511a8e27d9c8c7ba59cd1609c487f17d33

Contents?: true

Size: 691 Bytes

Versions: 12

Compression:

Stored size: 691 Bytes

Contents

# frozen_string_literal: true

module Pakyow
  module Presenter
    module Presentable
      def method_missing(method_name, *args, &block)
        if presentable?(method_name)
          @presentables[args.unshift(method_name).join(":").to_sym]
        else
          super
        end
      end

      def respond_to_missing?(method_name, include_private = false)
        presentable?(method_name) || super
      end

      private

      def presentable?(presentable_key)
        presentable_key = presentable_key.to_s
        instance_variable_defined?(:@presentables) && @presentables.any? { |key, _|
          key.to_s.start_with?(presentable_key)
        }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pakyow-presenter-1.0.6 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.5 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.4 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.3 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.2 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.1 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.0 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.0.rc5 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.0.rc4 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.0.rc3 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.0.rc2 lib/pakyow/presenter/presentable.rb
pakyow-presenter-1.0.0.rc1 lib/pakyow/presenter/presentable.rb