Class: Authorization::DevelopmentSupport::ChangeSupporter::AbstractCompoundAction

Inherits:
AbstractAction
  • Object
show all
Defined in:
lib/declarative_authorization/development_support/change_supporter.rb

Instance Method Summary (collapse)

Methods inherited from AbstractAction

#eql?, #inspect, readable_info, #resembles_any?, specific_actions

Instance Method Details

- (Object) apply(candidate)



288
289
290
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 288

def apply (candidate)
  @actions.all? {|action| action.apply(candidate)}
end

- (Object) hash



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

- (Boolean) resembles?(spec)



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

- (Boolean) reverse?(other)



292
293
294
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 292

def reverse? (other)
  @actions.any? {|action| action.reverse?(other)}
end

- (Object) to_a



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

- (Object) weight



284
285
286
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 284

def weight
  @actions.sum(&:weight) + 1
end