Class: Invoicing::TimeDependent::ClassInfo
- Inherits:
-
ClassInfo::Base
- Object
- ClassInfo::Base
- Invoicing::TimeDependent::ClassInfo
- Defined in:
- lib/invoicing/time_dependent.rb
Overview
Stores state in the ActiveRecord class object
Instance Attribute Summary
Attributes inherited from ClassInfo::Base
#all_args, #all_options, #current_args, #current_options, #model_class, #new_args, #previous_info
Instance Method Summary collapse
-
#initialize(model_class, previous_info, args) ⇒ ClassInfo
constructor
:nodoc:.
- #predecessors(record) ⇒ Object
Methods inherited from ClassInfo::Base
#get, #method, #option_defaults, #set
Constructor Details
permalink #initialize(model_class, previous_info, args) ⇒ ClassInfo
:nodoc:
369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/invoicing/time_dependent.rb', line 369 def initialize(model_class, previous_info, args) super # @predecessors is a hash of an ID pointing to the list of all objects which have that ID # as replaced_by_id value @predecessors = {} for record in model_class.cached_record_list id = get(record, :replaced_by_id) unless id.nil? @predecessors[id] ||= [] @predecessors[id] << record end end end |
Instance Method Details
permalink #predecessors(record) ⇒ Object
[View source]
383 384 385 |
# File 'lib/invoicing/time_dependent.rb', line 383 def predecessors(record) @predecessors[get(record, :id)] || [] end |