Sha256: 9857767ea30bc949896aca8ec6fe88469d51fb4df5011758446a52cf35565f12
Contents?: true
Size: 915 Bytes
Versions: 3
Compression:
Stored size: 915 Bytes
Contents
module Cocina class Instance class Action UnknownAction = Class.new(StandardError) ACTIONS = [:destroy, :create, :converge, :verify] unless defined? ACTIONS attr_reader :name def initialize(name) @after = [] @before = [] @name = name raise UnknownAction unless ACTIONS.include?(name) yield self if block_given? end def before(cmd = nil) return nil if create? return @before if cmd.nil? @before << cmd end def after(cmd = nil) return nil if destroy? return @after if cmd.nil? @after << cmd end # Check if this action is a destroy action # @return [Bool] def create? name == :create end # Check if this action is a destroy action # @return [Bool] def destroy? name == :destroy end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cocina-0.3.1 | lib/cocina/instance/action.rb |
cocina-0.2.2 | lib/cocina/instance/action.rb |
cocina-0.2.0 | lib/cocina/instance/action.rb |