Class: Authorization::DevelopmentSupport::ChangeSupporter::AbstractCompoundAction
- Inherits:
-
AbstractAction
- Object
- AbstractAction
- Authorization::DevelopmentSupport::ChangeSupporter::AbstractCompoundAction
show all
- Defined in:
- lib/declarative_authorization/development_support/change_supporter.rb
Instance Method Summary
collapse
#eql?, #inspect, readable_info, #resembles_any?, specific_actions
Instance Method Details
#apply(candidate) ⇒ Object
288
289
290
|
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 288
def apply (candidate)
@actions.all? {|action| action.apply(candidate)}
end
|
#hash ⇒ Object
300
301
302
|
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 300
def hash
@hash ||= @actions.inject(0) {|memo, action| memo += action.hash }
end
|
#resembles?(spec) ⇒ Boolean
304
305
306
307
308
309
310
|
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 304
def resembles? (spec)
@actions.any? {|action| action.resembles?(spec) } or
to_a.any? do |array|
min_length = [spec.length, array.length].min
array[0,min_length] == spec[0,min_length]
end
end
|
#reverse?(other) ⇒ Boolean
292
293
294
|
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 292
def reverse? (other)
@actions.any? {|action| action.reverse?(other)}
end
|
#to_a ⇒ Object
296
297
298
|
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 296
def to_a
@actions.inject([]) {|memo, action| memo += action.to_a.first.is_a?(Enumerable) ? action.to_a : [action.to_a]; memo }
end
|
#weight ⇒ Object
284
285
286
|
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 284
def weight
@actions.sum(&:weight) + 1
end
|