Sha256: 87080006424006111510aea108a08d43e225db094e9c4339ee48229049b89de9

Contents?: true

Size: 534 Bytes

Versions: 5

Compression:

Stored size: 534 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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chanko-2.0.4 lib/chanko/unit_proxy.rb
chanko-2.0.3 lib/chanko/unit_proxy.rb
chanko-2.0.2 lib/chanko/unit_proxy.rb
chanko-2.0.1 lib/chanko/unit_proxy.rb
chanko-2.0.0 lib/chanko/unit_proxy.rb