Module: Junos::Ez::Provider

Defined in:
lib/junos-ez/provider.rb

Defined Under Namespace

Classes: Parent

Constant Summary collapse

PROPERTIES =

all managed objects have the following properties:

[ 
  :_exist,          # exists in configuration (or should)
  :_active          # active in configuration (or should)
]

Class Method Summary collapse

Class Method Details

.attach_instance_variable(on_obj, varsname, new_obj) ⇒ Object

‘attach_instance_variable’ is the way to dynamically add an instance variable to the on_obj and “publish” it in the same way attr_accessor would.



64
65
66
67
68
69
70
71
# File 'lib/junos-ez/provider.rb', line 64

def self.attach_instance_variable( on_obj, varsname, new_obj )
  ivar = ("@" + varsname.to_s).to_sym
  on_obj.instance_variable_set( ivar, new_obj )
  on_obj.define_singleton_method( varsname ) do
    on_obj.instance_variable_get( ivar )
  end    
  on_obj.providers << varsname
end