class Granite::Action

Public Instance Methods

attributes_changed?(except: []) click to toggle source

Almost the same as Dirty `#changed?` method, but doesn't check subject reference key

# File lib/granite/action.rb, line 72
def attributes_changed?(except: [])
  except = Array.wrap(except).push(self.class.reflect_on_association(:subject).reference_key)
  changed_attributes.except(*except).present?
end
performable?() click to toggle source

Check if action is allowed to execute by current performer (see {Granite.performer}) and satisfy all defined preconditions

@return [Boolean] whether action is performable

# File lib/granite/action.rb, line 81
def performable?
  @performable = allowed? && satisfy_preconditions? unless instance_variable_defined?(:@performable)
  @performable
end

Protected Instance Methods

raise_validation_error(original_error = nil) click to toggle source
# File lib/granite/action.rb, line 88
def raise_validation_error(original_error = nil)
  fail ValidationError, self, original_error&.backtrace
end