Sha256: 64b1b390c63a748df4514aa1fb2a6628f4bf527b778c2bdb1cbc62af496c5a51

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

module Volt
  module Persistors
    # Implements the base persistor functionality.
    class Base
      def initialize(model)
        @model = model
      end

      def loaded(initial_state = nil)
        @model.change_state_to(:loaded_state, initial_state || :loaded)
      end

      def changed(attribute_name)
      end

      def added(model, index)
      end

      # For removed, the default action is to call changed for it
      def removed(attribute_name)
        changed(attribute_name)
      end

      # Called when the model is cleared (all child models removed)
      def clear
      end

      def event_added(event, first, first_for_event)
      end

      def event_removed(event, last, last_for_event)
      end

      # Specify if this collection should auto-generate id's
      def auto_generate_id
        false
      end

      # Find the root for this model
      def root_model
        node = @model

        loop do
          parent = node.parent
          if parent
            node = parent
          else
            break
          end
        end

        node
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
volt-0.9.4.pre3 lib/volt/models/persistors/base.rb
volt-0.9.4.pre2 lib/volt/models/persistors/base.rb
volt-0.9.4.pre1 lib/volt/models/persistors/base.rb
volt-0.9.3 lib/volt/models/persistors/base.rb
volt-0.9.3.pre6 lib/volt/models/persistors/base.rb
volt-0.9.3.pre5 lib/volt/models/persistors/base.rb
volt-0.9.3.pre4 lib/volt/models/persistors/base.rb
volt-0.9.3.pre3 lib/volt/models/persistors/base.rb
volt-0.9.3.pre2 lib/volt/models/persistors/base.rb