Class: Granite::Action
- Inherits:
-
Object
- Object
- Granite::Action
- Includes:
- AssignAttributes, Performer, Performing, Policies, Preconditions, Projectors, Subject, 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/preconditions.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/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, Performer, Performing, Policies, Preconditions, Projectors, Subject, Transaction, TransactionManager, Types Classes: Error, NotAllowedError, Rollback, SubjectNotFoundError, SubjectTypeMismatchError, ValidationError
Instance Attribute Summary
Attributes included from Preconditions
Class Method Summary collapse
Instance Method Summary collapse
-
#attributes_changed?(except: []) ⇒ Boolean
Almost the same as Dirty ‘#changed?` method, but doesn’t check subject reference key.
-
#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 AssignAttributes
Class Method Details
.i18n_scope ⇒ Object
69 70 71 |
# File 'lib/granite/action.rb', line 69 def self.i18n_scope :granite_action end |
Instance Method Details
#attributes_changed?(except: []) ⇒ Boolean
Almost the same as Dirty ‘#changed?` method, but doesn’t check subject reference key
75 76 77 78 |
# File 'lib/granite/action.rb', line 75 def attributes_changed?(except: []) except = Array.wrap(except).push(self.class.reflect_on_association(:subject).reference_key) changed_attributes.except(*except).present? end |
#performable? ⇒ Boolean
Check if action is allowed to execute by current performer (see Granite.performer) and satisfy all defined preconditions
84 85 86 87 88 89 |
# File 'lib/granite/action.rb', line 84 def performable? unless instance_variable_defined?(:@performable) @performable = allowed? && satisfy_preconditions? end @performable end |