Class: Granite::Action
- Inherits:
-
Object
- Object
- Granite::Action
- Includes:
- AssignAttributes, Instrumentation, Performer, Performing, Policies, Preconditions, Projectors, Subject, Translations, Base
- Defined in:
- lib/granite/action.rb,
lib/granite/action/error.rb,
lib/granite/action/subject.rb,
lib/granite/action/policies.rb,
lib/granite/action/performer.rb,
lib/granite/action/performing.rb,
lib/granite/action/projectors.rb,
lib/granite/action/transaction.rb,
lib/granite/action/precondition.rb,
lib/granite/action/translations.rb,
lib/granite/action/preconditions.rb,
lib/granite/action/instrumentation.rb,
lib/granite/action/types/collection.rb,
lib/granite/action/exceptions_handling.rb,
lib/granite/action/transaction_manager.rb,
lib/granite/action/policies/any_strategy.rb,
lib/granite/action/policies/always_allow_strategy.rb,
lib/granite/action/preconditions/base_precondition.rb,
lib/granite/action/preconditions/object_precondition.rb,
lib/granite/action/preconditions/embedded_precondition.rb,
lib/granite/action/policies/required_performer_strategy.rb,
lib/granite/action/transaction_manager/transactions_stack.rb
Defined Under Namespace
Modules: AssignAttributes, ExceptionsHandling, Instrumentation, Performer, Performing, Policies, Preconditions, Projectors, Subject, Transaction, TransactionManager, Translations, Types Classes: Error, NotAllowedError, Precondition, Rollback, SubjectNotFoundError, SubjectTypeMismatchError, ValidationError
Instance Attribute Summary
Attributes included from Preconditions
Instance Method Summary collapse
-
#attributes_changed?(except: []) ⇒ Boolean
Almost the same as Dirty `#changed?` method, but doesn't check subject reference key.
- #merge_errors(other_errors) ⇒ Object
-
#performable? ⇒ Boolean
Check if action is allowed to execute by current performer (see performer) and satisfy all defined preconditions.
Methods included from Policies
#allowed?, #authorize!, #perform, #perform!, #try_perform!
Methods included from Preconditions
#decline_with, #initialize, #satisfy_preconditions?
Methods included from Performer
Methods included from Subject
Methods included from Performing
#perform, #perform!, #performed?, #try_perform!
Methods included from Transaction
Methods included from Translations
Methods included from Util
#conditions_satisfied?, #evaluate
Methods included from AssignAttributes
Methods included from Instrumentation
#perform, #perform!, #try_perform!
Instance Method Details
#attributes_changed?(except: []) ⇒ Boolean
Almost the same as Dirty `#changed?` method, but doesn't check subject reference key
82 83 84 85 |
# File 'lib/granite/action.rb', line 82 def attributes_changed?(except: []) except = Array.wrap(except).push(self.class.reflect_on_association(:subject).reference_key) changed_attributes.except(*except).present? end |
#merge_errors(other_errors) ⇒ Object
67 68 69 70 71 |
# File 'lib/granite/action.rb', line 67 def merge_errors(other_errors) errors..deep_merge!(other_errors.) do |_, this, other| (this + other).uniq end end |
#performable? ⇒ Boolean
Check if action is allowed to execute by current performer (see Granite.performer) and satisfy all defined preconditions
91 92 93 94 |
# File 'lib/granite/action.rb', line 91 def performable? @performable = allowed? && satisfy_preconditions? unless instance_variable_defined?(:@performable) @performable end |