Module: Protector::Adapters::ActiveRecord::Base
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/protector/adapters/active_record/base.rb
Overview
Patches ActiveRecord::Base
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#creatable? ⇒ Boolean
Checks if current model can be created in the context of current subject.
-
#destroyable? ⇒ Boolean
Checks if current model can be destroyed in the context of current subject.
-
#protector_meta ⇒ Object
Storage for DSL::Meta::Box.
-
#updatable? ⇒ Boolean
Checks if current model can be updated in the context of current subject.
-
#visible? ⇒ Boolean
Checks if current model can be selected in the context of current subject.
Instance Method Details
#creatable? ⇒ Boolean
Checks if current model can be created in the context of current subject
98 99 100 101 |
# File 'lib/protector/adapters/active_record/base.rb', line 98 def creatable? fields = HashWithIndifferentAccess[changed.map{|field| [field, read_attribute(field)]}] .creatable?(fields) end |
#destroyable? ⇒ Boolean
Checks if current model can be destroyed in the context of current subject
110 111 112 |
# File 'lib/protector/adapters/active_record/base.rb', line 110 def destroyable? .destroyable? end |
#protector_meta ⇒ Object
Storage for DSL::Meta::Box
81 82 83 84 85 86 87 88 |
# File 'lib/protector/adapters/active_record/base.rb', line 81 def @protector_meta ||= self.class..evaluate( self.class, @protector_subject, self.class.column_names, self ) end |
#updatable? ⇒ Boolean
Checks if current model can be updated in the context of current subject
104 105 106 107 |
# File 'lib/protector/adapters/active_record/base.rb', line 104 def updatable? fields = HashWithIndifferentAccess[changed.map{|field| [field, read_attribute(field)]}] .updatable?(fields) end |
#visible? ⇒ Boolean
Checks if current model can be selected in the context of current subject
91 92 93 94 95 |
# File 'lib/protector/adapters/active_record/base.rb', line 91 def visible? .relation.where( self.class.primary_key => id ).any? end |