Class: Wakame::ConstantCounter

Inherits:
InstanceCounter show all
Defined in:
lib/wakame/instance_counter.rb

Constant Summary

Constants included from AttributeHelper

AttributeHelper::CLASS_TYPE_KEY, AttributeHelper::CONVERT_CLASSES, AttributeHelper::PRIMITIVE_CLASSES

Instance Method Summary collapse

Methods inherited from InstanceCounter

#bind_resource, #resource

Methods included from AttributeHelper

#dump_attrs, #retrieve_attr_attribute

Constructor Details

#initialize(resource) ⇒ ConstantCounter

Returns a new instance of ConstantCounter.



27
28
29
30
# File 'lib/wakame/instance_counter.rb', line 27

def initialize(resource)
  @instance_count = 1
  bind_resource(resource)
end

Instance Method Details

#instance_countObject



32
33
34
# File 'lib/wakame/instance_counter.rb', line 32

def instance_count
  @instance_count
end

#instance_count=(count) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/wakame/instance_counter.rb', line 36

def instance_count=(count)
  raise OutOfLimitRangeError unless check_hard_limit(count)
  if @instance_count != count
    prev = @instance_count
    @instance_count = count
    ED.fire_event(Event::InstanceCountChanged.new(@resource, prev, count))
  end
end