Class: Authorization::DevelopmentSupport::ChangeSupporter::AbstractAction

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.readable_info(info) ⇒ Object



274
275
276
277
278
279
280
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 274

def self.readable_info (info)
  if info.respond_to?(:to_sym)
    info.to_sym.inspect
  else
    info.inspect
  end
end

.specific_actions(candidate) ⇒ Object

returns a list of instances of the action that may be applied

Raises:

  • (NotImplementedError)


236
237
238
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 236

def self.specific_actions (candidate)
  raise NotImplementedError, "Not yet?"
end

Instance Method Details

#apply(candidate) ⇒ Object

applies the specific action on the given candidate

Raises:

  • (NotImplementedError)


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

def apply (candidate)
  raise NotImplementedError, "Not yet?"
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

def eql? (other)
  other.class == self.class and hash == other.hash
end

#hashObject



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

def hash
  @hash ||= to_a.hash
end

#inspectObject



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

def inspect
  "#{self.class.name.demodulize} #{hash} #{to_a.hash} (#{to_a[1..-1].collect {|info| self.class.readable_info(info)} * ','})"
end

#resembles?(spec) ⇒ Boolean

Returns:

  • (Boolean)


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

def resembles? (spec)
  min_length = [spec.length, to_a.length].min
  to_a[0,min_length] == spec[0,min_length]
end

#resembles_any?(specs) ⇒ Boolean

Returns:

  • (Boolean)


270
271
272
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 270

def resembles_any? (specs)
  specs.any? {|spec| resembles?(spec) }
end

#reverse?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

def reverse? (other)
  false
end

#to_aObject



261
262
263
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 261

def to_a
  [:abstract]
end

#weightObject



231
232
233
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 231

def weight
  1
end