Class: RedShift::State

Inherits:
Object show all
Defined in:
lib/redshift/state.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(n, context) ⇒ State

Returns a new instance of State.



4
5
6
7
8
# File 'lib/redshift/state.rb', line 4

def initialize n, context
  @name = n
  @persist_name = "#{context}::#{n}".intern
  @context = context
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/redshift/state.rb', line 2

def name
  @name
end

#persist_nameObject (readonly)

Returns the value of attribute persist_name.



2
3
4
# File 'lib/redshift/state.rb', line 2

def persist_name
  @persist_name
end

Class Method Details

._load(str) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/redshift/state.rb', line 14

def self._load str
  pn = str.intern
  ## could cache this lookup in a hash
  ObjectSpace.each_object(State) { |st|
    if st.persist_name == pn
      return st
    end
  }
end

Instance Method Details

#_dump(depth) ⇒ Object



10
11
12
# File 'lib/redshift/state.rb', line 10

def _dump depth
  @persist_name.to_s
end

#inspectObject



28
29
30
# File 'lib/redshift/state.rb', line 28

def inspect
  "<#{@name}>"
end

#to_sObject



24
25
26
# File 'lib/redshift/state.rb', line 24

def to_s
  @name.to_s
end