Module: DailyAffirmation::Affirmations::ClassMethods
- Defined in:
- lib/daily_affirmation/affirmations.rb
Instance Method Summary collapse
- #affirmations ⇒ Object
- #affirms(attribute, opts = {}) ⇒ Object
- #affirms_absence_of(attribute, opts = {}) ⇒ Object
- #affirms_acceptance_of(attribute, opts = {}) ⇒ Object
- #affirms_confirmation_of(attribute, opts = {}) ⇒ Object
- #affirms_equality_of(attribute, opts = {}) ⇒ Object
- #affirms_exclusion_of(attribute, opts = {}) ⇒ Object
- #affirms_format_of(attribute, opts = {}) ⇒ Object
- #affirms_inclusion_of(attribute, opts = {}) ⇒ Object
- #affirms_length_of(attribute, opts = {}) ⇒ Object
- #affirms_numericality_of(attribute, opts = {}) ⇒ Object
- #affirms_presence_of(attribute, opts = {}) ⇒ Object
- #affirms_valid_date(attribute, opts = {}) ⇒ Object
Instance Method Details
#affirmations ⇒ Object
149 150 151 |
# File 'lib/daily_affirmation/affirmations.rb', line 149 def affirmations @affirmations ||= [] end |
#affirms(attribute, opts = {}) ⇒ Object
143 144 145 146 147 |
# File 'lib/daily_affirmation/affirmations.rb', line 143 def affirms(attribute, opts = {}) affirmations << { :attribute => attribute, :type => :custom }.merge(opts) end |
#affirms_absence_of(attribute, opts = {}) ⇒ Object
72 73 74 75 76 |
# File 'lib/daily_affirmation/affirmations.rb', line 72 def affirms_absence_of(attribute, opts = {}) affirmations << { :attribute => attribute, :type => :absence }.merge(opts) end |
#affirms_acceptance_of(attribute, opts = {}) ⇒ Object
78 79 80 81 82 |
# File 'lib/daily_affirmation/affirmations.rb', line 78 def affirms_acceptance_of(attribute, opts = {}) affirmations << { :attribute => attribute, :type => :acceptance }.merge(opts) end |
#affirms_confirmation_of(attribute, opts = {}) ⇒ Object
84 85 86 87 88 |
# File 'lib/daily_affirmation/affirmations.rb', line 84 def affirms_confirmation_of(attribute, opts = {}) affirmations << { :attribute => attribute, :type => :confirmation }.merge(opts) end |
#affirms_equality_of(attribute, opts = {}) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/daily_affirmation/affirmations.rb', line 90 def affirms_equality_of(attribute, opts = {}) opts[:value] ||= "" affirmations << { :attribute => attribute, :type => :equality }.merge(opts) end |
#affirms_exclusion_of(attribute, opts = {}) ⇒ Object
97 98 99 100 101 102 |
# File 'lib/daily_affirmation/affirmations.rb', line 97 def affirms_exclusion_of(attribute, opts = {}) opts[:list] ||= [] affirmations << { :attribute => attribute, :type => :exclusion }.merge(opts) end |
#affirms_format_of(attribute, opts = {}) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/daily_affirmation/affirmations.rb', line 104 def affirms_format_of(attribute, opts = {}) opts[:regex] ||= // affirmations << { :attribute => attribute, :type => :format }.merge(opts) end |
#affirms_inclusion_of(attribute, opts = {}) ⇒ Object
111 112 113 114 115 116 |
# File 'lib/daily_affirmation/affirmations.rb', line 111 def affirms_inclusion_of(attribute, opts = {}) opts[:list] ||= [] affirmations << { :attribute => attribute, :type => :inclusion }.merge(opts) end |
#affirms_length_of(attribute, opts = {}) ⇒ Object
118 119 120 121 122 123 |
# File 'lib/daily_affirmation/affirmations.rb', line 118 def affirms_length_of(attribute, opts = {}) opts[:range] ||= 0..0 affirmations << { :attribute => attribute, :type => :length }.merge(opts) end |
#affirms_numericality_of(attribute, opts = {}) ⇒ Object
125 126 127 128 129 |
# File 'lib/daily_affirmation/affirmations.rb', line 125 def affirms_numericality_of(attribute, opts = {}) affirmations << { :attribute => attribute, :type => :numericality }.merge(opts) end |
#affirms_presence_of(attribute, opts = {}) ⇒ Object
131 132 133 134 135 |
# File 'lib/daily_affirmation/affirmations.rb', line 131 def affirms_presence_of(attribute, opts = {}) affirmations << { :attribute => attribute, :type => :presence }.merge(opts) end |
#affirms_valid_date(attribute, opts = {}) ⇒ Object
137 138 139 140 141 |
# File 'lib/daily_affirmation/affirmations.rb', line 137 def affirms_valid_date(attribute, opts = {}) affirmations << { :attribute => attribute, :type => :date }.merge(opts) end |