Sha256: 3d0cb4624ca22f6307e497b061f6ea70d53957f633ee68e9f57fa700f926cb1f

Contents?: true

Size: 946 Bytes

Versions: 4

Compression:

Stored size: 946 Bytes

Contents

module Volt
  module Persistors
    # Implements the base persistor functionality.
    class Base
      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

      # 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

4 entries across 4 versions & 1 rubygems

Version Path
volt-0.9.3.pre1 lib/volt/models/persistors/base.rb
volt-0.9.2 lib/volt/models/persistors/base.rb
volt-0.9.1 lib/volt/models/persistors/base.rb
volt-0.9.1.pre5 lib/volt/models/persistors/base.rb