Class: CatTree::Observer::ArBase
- Inherits:
-
Object
- Object
- CatTree::Observer::ArBase
- Defined in:
- lib/cat_tree/observer/target_set/ar_base.rb
Instance Attribute Summary collapse
-
#callers ⇒ Object
readonly
Returns the value of attribute callers.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(object) ⇒ ArBase
constructor
A new instance of ArBase.
- #key ⇒ Object
- #merge(other) ⇒ Object
- #title ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(object) ⇒ ArBase
Returns a new instance of ArBase.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/cat_tree/observer/target_set/ar_base.rb', line 6 def initialize(object) return unless object_valid?(object) @valid = true @model = object.class.name @model_id = object.id @count = 1 @callers = [] record_backtrace if CatTree::Config.backtrace end |
Instance Attribute Details
#callers ⇒ Object (readonly)
Returns the value of attribute callers.
4 5 6 |
# File 'lib/cat_tree/observer/target_set/ar_base.rb', line 4 def callers @callers end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
4 5 6 |
# File 'lib/cat_tree/observer/target_set/ar_base.rb', line 4 def count @count end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 |
# File 'lib/cat_tree/observer/target_set/ar_base.rb', line 24 def ==(other) key == other.key end |
#key ⇒ Object
28 29 30 |
# File 'lib/cat_tree/observer/target_set/ar_base.rb', line 28 def key [@model, @model_id] end |
#merge(other) ⇒ Object
18 19 20 21 22 |
# File 'lib/cat_tree/observer/target_set/ar_base.rb', line 18 def merge(other) @count += other.count @callers.concat(other.callers) self end |
#title ⇒ Object
36 37 38 |
# File 'lib/cat_tree/observer/target_set/ar_base.rb', line 36 def title "#{@model}(id:#{@model_id})" end |
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/cat_tree/observer/target_set/ar_base.rb', line 32 def valid? !!@valid end |