Sha256: 44c9d91a09c552fb41c08daeee705085db429d2e1a88ad8d8491563eaf206a22

Contents?: true

Size: 655 Bytes

Versions: 9

Compression:

Stored size: 655 Bytes

Contents

require "delegate"

module Chanko
  class UnitProxy
    attr_reader :unit

    def self.generate_prefix(unit_name)
      "__#{unit_name}_"
    end

    def initialize(unit, context)
      @unit    = unit
      @context = context
    end

    def active?(options = {})
      @unit.active?(@context, options)
    end

    private

    def prefix
      self.class.generate_prefix(@unit.unit_name)
    end

    def method_missing(method_name, *args, &block)
      @context.send("#{prefix}#{method_name}", *args, &block)
    end

    def respond_to_missing?(method_name, include_private)
      @context.respond_to?("#{prefix}#{method_name}")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
chanko-2.3.0 lib/chanko/unit_proxy.rb
chanko-2.2.1 lib/chanko/unit_proxy.rb
chanko-2.2.0 lib/chanko/unit_proxy.rb
chanko-2.1.1 lib/chanko/unit_proxy.rb
chanko-2.1.0 lib/chanko/unit_proxy.rb
chanko-2.0.8 lib/chanko/unit_proxy.rb
chanko-2.0.7 lib/chanko/unit_proxy.rb
chanko-2.0.6 lib/chanko/unit_proxy.rb
chanko-2.0.5 lib/chanko/unit_proxy.rb