Class: Fraternity::Pledge
- Inherits:
-
Object
- Object
- Fraternity::Pledge
- Includes:
- Lotus::Validations
- Defined in:
- lib/fraternity/pledge.rb
Instance Attribute Summary collapse
-
#accepted_at ⇒ Object
Returns the value of attribute accepted_at.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#initiation_number ⇒ Object
Returns the value of attribute initiation_number.
-
#invited_at ⇒ Object
Returns the value of attribute invited_at.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #bid! ⇒ Object
- #cross!(token) ⇒ Object
- #crossed? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Pledge
constructor
A new instance of Pledge.
- #invite! ⇒ Object
- #invited? ⇒ Boolean
- #merge(attributes = {}) ⇒ Object
- #ready? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Pledge
Returns a new instance of Pledge.
13 14 15 16 |
# File 'lib/fraternity/pledge.rb', line 13 def initialize(attributes={}) @id, @email, @first_name, @last_name, @token, @initiation_number, @invited_at, @accepted_at = attributes.values_at :id, :email, :first_name, :last_name, :token, :initiation_number, :invited_at, :accepted_at end |
Instance Attribute Details
#accepted_at ⇒ Object
Returns the value of attribute accepted_at.
7 8 9 |
# File 'lib/fraternity/pledge.rb', line 7 def accepted_at @accepted_at end |
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/fraternity/pledge.rb', line 7 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
7 8 9 |
# File 'lib/fraternity/pledge.rb', line 7 def first_name @first_name end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/fraternity/pledge.rb', line 7 def id @id end |
#initiation_number ⇒ Object
Returns the value of attribute initiation_number.
7 8 9 |
# File 'lib/fraternity/pledge.rb', line 7 def initiation_number @initiation_number end |
#invited_at ⇒ Object
Returns the value of attribute invited_at.
7 8 9 |
# File 'lib/fraternity/pledge.rb', line 7 def invited_at @invited_at end |
#last_name ⇒ Object
Returns the value of attribute last_name.
7 8 9 |
# File 'lib/fraternity/pledge.rb', line 7 def last_name @last_name end |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/fraternity/pledge.rb', line 7 def token @token end |
Instance Method Details
#bid! ⇒ Object
18 19 20 |
# File 'lib/fraternity/pledge.rb', line 18 def bid! Bidder.new(self).bid! end |
#cross!(token) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/fraternity/pledge.rb', line 30 def cross!(token) raise Fraternity::PerpError if !invited? raise Fraternity::TokenMismatchError.new(self.token, token) if token != self.token self.accepted_at = DateTime.now Repositories::PledgeRepository.persist self end |
#crossed? ⇒ Boolean
37 38 39 |
# File 'lib/fraternity/pledge.rb', line 37 def crossed? !self.accepted_at.nil? end |
#invite! ⇒ Object
22 23 24 |
# File 'lib/fraternity/pledge.rb', line 22 def invite! self.invited_at = DateTime.now end |
#invited? ⇒ Boolean
26 27 28 |
# File 'lib/fraternity/pledge.rb', line 26 def invited? !self.invited_at.nil? end |
#merge(attributes = {}) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/fraternity/pledge.rb', line 45 def merge(attributes={}) attributes.each_pair do |attribute, value| method = "#{attribute}=" self.public_send method, value if self.respond_to? method end end |
#ready? ⇒ Boolean
41 42 43 |
# File 'lib/fraternity/pledge.rb', line 41 def ready? self.invited? && !self.crossed? end |