Class: SimpleRules::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_rules/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action, object_name, error_message, &block) ⇒ Rule

Returns a new instance of Rule.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
# File 'lib/simple_rules/rule.rb', line 5

def initialize (action, object_name, error_message, &block)
  @action        = action
  @object_name  = object_name
  @block         = block
  @error_message = error_message

  raise ArgumentError, 'Block is not given' unless block
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



3
4
5
# File 'lib/simple_rules/rule.rb', line 3

def action
  @action
end

#blockObject

Returns the value of attribute block.



3
4
5
# File 'lib/simple_rules/rule.rb', line 3

def block
  @block
end

#error_messageObject

Returns the value of attribute error_message.



3
4
5
# File 'lib/simple_rules/rule.rb', line 3

def error_message
  @error_message
end

#object_nameObject

Returns the value of attribute object_name.



3
4
5
# File 'lib/simple_rules/rule.rb', line 3

def object_name
  @object_name
end