lib/protector/adapters/sequel/dataset.rb in protector-0.6.4 vs lib/protector/adapters/sequel/dataset.rb in protector-0.7.0
- old
+ new
@@ -17,11 +17,11 @@
# Mutate entity through `row_proc` if available and then protect
#
# @param entity [Object] Entity coming from Dataset
def call(entity)
entity = mutator.call(entity) if mutator
- return entity if !entity.respond_to?(:restrict!)
+ return entity unless entity.respond_to?(:restrict!)
entity.restrict!(@subject)
end
end
included do |klass|
@@ -32,10 +32,14 @@
def creatable?
model.new.restrict!(protector_subject).creatable?
end
+ def can?(action, field=false)
+ protector_meta.can?(action, field)
+ end
+
# Gets {Protector::DSL::Meta::Box} of this dataset
def protector_meta(subject=protector_subject)
model.protector_meta.evaluate(subject)
end
@@ -65,6 +69,6 @@
relation
end
end
end
end
-end
\ No newline at end of file
+end