Sha256: 1fffd98449dfdc889016cc89b771a14cf6b5e2ad2e57a6a4064997c804ada3c2

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 Bytes

Contents

module Hotcell
  class Manipulator
    module Mixin
      extend ActiveSupport::Concern

      included do
        class_attribute :manipulator_methods, instance_writter: false
        self.manipulator_methods = Set.new

        def self.manipulator *methods
          self.manipulator_methods = Set.new(manipulator_methods.to_a + methods.flatten.map(&:to_s))
        end
      end

      def to_manipulator
        self
      end

      def manipulator_invoke method, *arguments
        send(method, *arguments) if manipulator_methods.include? method
      end
    end

    include Mixin

    def manipulator_methods
      @manipulator_methods ||= Set.new((self.class.public_instance_methods -
        Hotcell::Manipulator.public_instance_methods).map(&:to_s))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hotcell-0.1.0 lib/hotcell/manipulator.rb
hotcell-0.0.1 lib/hotcell/manipulator.rb