Sha256: 30581b40c5a4257c444c4fb9c7d8d3f4333dc88a8876cc09425d17b0bb7e4f97

Contents?: true

Size: 741 Bytes

Versions: 7

Compression:

Stored size: 741 Bytes

Contents

require 'active_support/core_ext/class/attribute'

module Memento::Action
  class Base
    def initialize(state)
      @state = state
    end

    attr_reader :state
    class_attribute :action_types, :instance_reader => false, :instance_writer => false
    self.action_types = []

    def record
      @state.record
    end

    def record_data
      @state.record_data
    end

    def fetch?
      true
    end

    def self.inherited(child)
      self.action_types << child.name.demodulize.underscore
    end

    private

    def new_object
      object = @state.record_type.constantize.new
      yield(object) if block_given?
      object
    end
  end
end

Dir["#{File.dirname(__FILE__)}/action/*.rb"].each { |action| require action }

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
memento-0.5.2 lib/memento/action.rb
memento-0.5.1 lib/memento/action.rb
memento-0.5.0 lib/memento/action.rb
memento-0.4.3 lib/memento/action.rb
memento-0.4.2 lib/memento/action.rb
memento-0.4.1 lib/memento/action.rb
memento-0.4.0 lib/memento/action.rb