Class: ObjectAttorney::Validations::Custom

Inherits:
Object
  • Object
show all
Defined in:
lib/object_attorney/validations/custom.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Custom

Returns a new instance of Custom.



8
9
10
11
12
# File 'lib/object_attorney/validations/custom.rb', line 8

def initialize(args)
  @methods = args

  @options = args.extract_options!
end

Instance Attribute Details

#attorney=(value) ⇒ Object (writeonly)

Sets the attribute attorney

Parameters:

  • value

    the value to set the attribute attorney to.



6
7
8
# File 'lib/object_attorney/validations/custom.rb', line 6

def attorney=(value)
  @attorney = value
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/object_attorney/validations/custom.rb', line 4

def options
  @options
end

Instance Method Details

#validate(defendant) ⇒ Object



14
15
16
17
18
# File 'lib/object_attorney/validations/custom.rb', line 14

def validate(defendant)
  [*@methods].all? do |method|
    Helpers.call_method!(@attorney, method, defendant)
  end
end