Sha256: 1602d6da3de65569dddffd3c65727afbfb898d9e154acd9fb256d37f5e163728

Contents?: true

Size: 567 Bytes

Versions: 5

Compression:

Stored size: 567 Bytes

Contents

module Osheet::Instance

  private

  OSHEET_IVAR_NS = "_osheet_"

  def get_ivar(name)
    instance_variable_get(ivar_name(name))
  end

  def set_ivar(name, value)
    instance_variable_set(ivar_name(name), value)
  end

  def push_ivar(name, value)
    get_ivar(name) << value
  end

  def ivar_name(name)
    "@#{OSHEET_IVAR_NS}#{name}"
  end

  def set_binding_ivars(binding)
    binding.eval('instance_variables').
    reject{|ivar| ivar =~ /^@#{OSHEET_IVAR_NS}/}.
    each do |ivar|
      instance_variable_set(ivar, binding.eval(ivar.to_s))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
osheet-0.10.0 lib/osheet/instance.rb
osheet-0.9.2 lib/osheet/instance.rb
osheet-0.9.1 lib/osheet/instance.rb
osheet-0.9.0 lib/osheet/instance.rb
osheet-0.8.0 lib/osheet/instance.rb