Sha256: 7924fc34cbbde4262fd03eb0647ae95fafbc654f2dbe54a0bb64cc19fddd09e8

Contents?: true

Size: 534 Bytes

Versions: 3

Compression:

Stored size: 534 Bytes

Contents

require "delegate"

module Nyanko
  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

3 entries across 3 versions & 1 rubygems

Version Path
nyanko-0.0.9 lib/nyanko/unit_proxy.rb
nyanko-0.0.8 lib/nyanko/unit_proxy.rb
nyanko-0.0.7 lib/nyanko/unit_proxy.rb