Module: DailyAffirmation::Affirmations::ClassMethods

Defined in:
lib/daily_affirmation/affirmations.rb

Instance Method Summary collapse

Instance Method Details

#affirmationsObject



134
135
136
# File 'lib/daily_affirmation/affirmations.rb', line 134

def affirmations
  @affirmations ||= []
end

#affirms(attribute, opts = {}) ⇒ Object



128
129
130
131
132
# File 'lib/daily_affirmation/affirmations.rb', line 128

def affirms(attribute, opts = {})
  affirmations << {
    :attribute => attribute, :type => :custom
  }.merge(opts)
end

#affirms_absence_of(attribute, opts = {}) ⇒ Object



57
58
59
60
61
# File 'lib/daily_affirmation/affirmations.rb', line 57

def affirms_absence_of(attribute, opts = {})
  affirmations << {
    :attribute => attribute, :type => :absence
  }.merge(opts)
end

#affirms_acceptance_of(attribute, opts = {}) ⇒ Object



63
64
65
66
67
# File 'lib/daily_affirmation/affirmations.rb', line 63

def affirms_acceptance_of(attribute, opts = {})
  affirmations << {
    :attribute => attribute, :type => :acceptance
  }.merge(opts)
end

#affirms_confirmation_of(attribute, opts = {}) ⇒ Object



69
70
71
72
73
# File 'lib/daily_affirmation/affirmations.rb', line 69

def affirms_confirmation_of(attribute, opts = {})
  affirmations << {
    :attribute => attribute, :type => :confirmation
  }.merge(opts)
end

#affirms_equality_of(attribute, opts = {}) ⇒ Object



75
76
77
78
79
80
# File 'lib/daily_affirmation/affirmations.rb', line 75

def affirms_equality_of(attribute, opts = {})
  opts[:value] ||= ""
  affirmations << {
    :attribute => attribute, :type => :equality
  }.merge(opts)
end

#affirms_exclusion_of(attribute, opts = {}) ⇒ Object



82
83
84
85
86
87
# File 'lib/daily_affirmation/affirmations.rb', line 82

def affirms_exclusion_of(attribute, opts = {})
  opts[:list] ||= []
  affirmations << {
    :attribute => attribute, :type => :exclusion
  }.merge(opts)
end

#affirms_format_of(attribute, opts = {}) ⇒ Object



89
90
91
92
93
94
# File 'lib/daily_affirmation/affirmations.rb', line 89

def affirms_format_of(attribute, opts = {})
  opts[:regex] ||= //
  affirmations << {
    :attribute => attribute, :type => :format
  }.merge(opts)
end

#affirms_inclusion_of(attribute, opts = {}) ⇒ Object



96
97
98
99
100
101
# File 'lib/daily_affirmation/affirmations.rb', line 96

def affirms_inclusion_of(attribute, opts = {})
  opts[:list] ||= []
  affirmations << {
    :attribute => attribute, :type => :inclusion
  }.merge(opts)
end

#affirms_length_of(attribute, opts = {}) ⇒ Object



103
104
105
106
107
108
# File 'lib/daily_affirmation/affirmations.rb', line 103

def affirms_length_of(attribute, opts = {})
  opts[:range] ||= 0..0
  affirmations << {
    :attribute => attribute, :type => :length
  }.merge(opts)
end

#affirms_numericality_of(attribute, opts = {}) ⇒ Object



110
111
112
113
114
# File 'lib/daily_affirmation/affirmations.rb', line 110

def affirms_numericality_of(attribute, opts = {})
  affirmations << {
    :attribute => attribute, :type => :numericality
  }.merge(opts)
end

#affirms_presence_of(attribute, opts = {}) ⇒ Object



116
117
118
119
120
# File 'lib/daily_affirmation/affirmations.rb', line 116

def affirms_presence_of(attribute, opts = {})
  affirmations << {
    :attribute => attribute, :type => :presence
  }.merge(opts)
end

#affirms_valid_date(attribute, opts = {}) ⇒ Object



122
123
124
125
126
# File 'lib/daily_affirmation/affirmations.rb', line 122

def affirms_valid_date(attribute, opts = {})
  affirmations << {
    :attribute => attribute, :type => :date
  }.merge(opts)
end