Class: Nyanko::UnitProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/nyanko/unit_proxy.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unit, context) ⇒ UnitProxy

Returns a new instance of UnitProxy.



11
12
13
14
# File 'lib/nyanko/unit_proxy.rb', line 11

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



26
27
28
# File 'lib/nyanko/unit_proxy.rb', line 26

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

Instance Attribute Details

#unitObject (readonly)

Returns the value of attribute unit.



5
6
7
# File 'lib/nyanko/unit_proxy.rb', line 5

def unit
  @unit
end

Class Method Details

.generate_prefix(unit_name) ⇒ Object



7
8
9
# File 'lib/nyanko/unit_proxy.rb', line 7

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

Instance Method Details

#active?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/nyanko/unit_proxy.rb', line 16

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