Class: Aequitas::Rule::SkipCondition
- Inherits:
-
Object
- Object
- Aequitas::Rule::SkipCondition
- Extended by:
- ValueObject
- Defined in:
- lib/aequitas/rule/skip_condition.rb
Instance Attribute Summary collapse
-
#allow_blank ⇒ Object
readonly
Returns the value of attribute allow_blank.
-
#allow_nil ⇒ Object
readonly
Returns the value of attribute allow_nil.
Attributes included from ValueObject
Instance Method Summary collapse
-
#allow_blank! ⇒ self
Set the receiver to allow blank values.
-
#allow_blank? ⇒ Boolean
Inquire whether the receiver is configured to allow blank values.
-
#allow_nil! ⇒ self
Set the receiver to allow nil values.
-
#allow_nil? ⇒ Boolean
Inquire whether the receiver is configured to allow nil values.
-
#default_to_allowing_blank! ⇒ self
Set the receiver to allow blank values if a value has not already been set.
-
#default_to_allowing_nil! ⇒ self
Set the receiver to allow nil values if a value has not already been set.
-
#initialize(options = {}) ⇒ SkipCondition
constructor
A new instance of SkipCondition.
-
#reject_blank! ⇒ self
Set the receiver to reject blank values.
-
#reject_nil! ⇒ self
Set the receiver to reject nil values.
-
#skip?(value) ⇒ Boolean
Test a value to determine if it should be skipped, according to the receiver’s configuration.
Methods included from ValueObject
Constructor Details
#initialize(options = {}) ⇒ SkipCondition
Returns a new instance of SkipCondition.
16 17 18 19 |
# File 'lib/aequitas/rule/skip_condition.rb', line 16 def initialize( = {}) @allow_nil = !![:allow_nil] if .include?(:allow_nil) @allow_blank = !![:allow_blank] if .include?(:allow_blank) end |
Instance Attribute Details
#allow_blank ⇒ Object (readonly)
Returns the value of attribute allow_blank.
14 15 16 |
# File 'lib/aequitas/rule/skip_condition.rb', line 14 def allow_blank @allow_blank end |
#allow_nil ⇒ Object (readonly)
Returns the value of attribute allow_nil.
13 14 15 |
# File 'lib/aequitas/rule/skip_condition.rb', line 13 def allow_nil @allow_nil end |
Instance Method Details
#allow_blank! ⇒ self
Set the receiver to allow blank values
63 64 65 66 |
# File 'lib/aequitas/rule/skip_condition.rb', line 63 def allow_blank! @allow_blank = true self end |
#allow_blank? ⇒ Boolean
Inquire whether the receiver is configured to allow blank values
48 49 50 |
# File 'lib/aequitas/rule/skip_condition.rb', line 48 def allow_blank? @allow_blank.nil? ? false : @allow_blank end |
#allow_nil! ⇒ self
Set the receiver to allow nil values
55 56 57 58 |
# File 'lib/aequitas/rule/skip_condition.rb', line 55 def allow_nil! @allow_nil = true self end |
#allow_nil? ⇒ Boolean
Inquire whether the receiver is configured to allow nil values
41 42 43 |
# File 'lib/aequitas/rule/skip_condition.rb', line 41 def allow_nil? @allow_nil.nil? ? false : @allow_nil end |
#default_to_allowing_blank! ⇒ self
Set the receiver to allow blank values
if a value has not already been set
97 98 99 100 |
# File 'lib/aequitas/rule/skip_condition.rb', line 97 def default_to_allowing_blank! allow_blank! if allow_blank.nil? self end |
#default_to_allowing_nil! ⇒ self
Set the receiver to allow nil values
if a value has not already been set
88 89 90 91 |
# File 'lib/aequitas/rule/skip_condition.rb', line 88 def default_to_allowing_nil! allow_nil! if allow_nil.nil? self end |
#reject_blank! ⇒ self
Set the receiver to reject blank values
79 80 81 82 |
# File 'lib/aequitas/rule/skip_condition.rb', line 79 def reject_blank! @allow_blank = false self end |
#reject_nil! ⇒ self
Set the receiver to reject nil values
71 72 73 74 |
# File 'lib/aequitas/rule/skip_condition.rb', line 71 def reject_nil! @allow_nil = false self end |
#skip?(value) ⇒ Boolean
Test a value to determine if it should be skipped,
according to the receiver's configuration
28 29 30 31 32 33 34 35 36 |
# File 'lib/aequitas/rule/skip_condition.rb', line 28 def skip?(value) if value.nil? @allow_nil.nil? ? allow_blank? : allow_nil? elsif Aequitas.blank?(value) allow_blank? else false end end |