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

#apply(candidate) ⇒ Object



246
247
248
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 246

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

#hashObject



258
259
260
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 258

def hash
  @hash ||= @actions.inject(0) {|memo, action| memo += action.hash }
end

#resembles?(spec) ⇒ Boolean

Returns:

  • (Boolean)


262
263
264
265
266
267
268
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 262

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

Returns:

  • (Boolean)


250
251
252
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 250

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

#to_aObject



254
255
256
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 254

def to_a
  @actions.inject([]) {|memo, action| memo += action.to_a.first.is_a?(Enumerable) ? action.to_a : [action.to_a]; memo }
end

#weightObject



242
243
244
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 242

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