rsvp 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2I2YzNjOTE0YmYyNTg4ZmNiYjdiOWVmOGMwZjc0NmY0N2JkYjQyOQ==
4
+ NTcxN2E0MmZmOGM1MTcwYTVkOTY1ODdjYTczYWY5ZTdmMzUxMTNjOA==
5
5
  data.tar.gz: !binary |-
6
- NGQ1ZGQzZjNjMDUyZTQ0MmU3MjA5ZTViZDY5ZWU2OTViZTYyMTI0NA==
6
+ OTAzZGVlYjkyZmY2ZjZjMGVkZTBmNDcyODBhZGM4OGM2N2VlYzM0YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTI4NDVlMTJlNWMwZGQwZDQ3MzQzZmNmMTQwYjk2NDBlNTYwNjY1OTllODYw
10
- NzFkZDU2NDQzYmM3YzU1MDNiYTFlYjg1MTMzNTA5NTMxNzAyOGRkMWNhM2Q0
11
- NzE1MzRlOWFkYWY0YzZlZDM2MmYwYzczNjY1YzMwOTI3NTg0NGY=
9
+ MzlhNzMyOTQxMzczNWExYWY0ZGQ3OWJjZDRmY2EzMGQwOTZhMWE3ZmExZDVi
10
+ NTMxY2RjNDI2YTQwOGVkYmQwYjhiYjlkMzZjNzI4M2NjNzMwYTg1OWI4MmY2
11
+ MzkxZTQ4ZmE4Y2ZjOTM1ZmFkNGM1Zjg0MTBlMWFjY2ZhNGJmNTY=
12
12
  data.tar.gz: !binary |-
13
- Nzc5NGVkZTQ2MzNlOGEwMjVkNzI0NDM3MjdkNDUxNWQyMWU2NmVlZmY5MzA1
14
- Y2E5M2Y2NzM1ZWQzZjJjZWYwZDM3NDVjZjAzYjFkYzM2ZGQzNmY0YmM0OGZk
15
- NjVhMzIwMDUyN2NhMDgzYTZkMGVkNzM5YjJlMmMwNjlhYTQ1ZWU=
13
+ YjA0OGEyZjgxNjA3ZmU2ZThjYTY4ZTgxZmNjODI1N2EyZWFmMzVlMTkzNmFk
14
+ NzYyOWU1Njk2MWYwZmNmYTcxZDFkNzU4YTNmNjg0NDExYjk3YmRlN2ZlYWM5
15
+ M2NjY2IzYWMwMDk1NGM0YTc1YjNiZmRhNTljOWY4NWRiNWE2YTk=
@@ -1,12 +1,10 @@
1
1
  module Rsvp
2
2
  class Family < ActiveRecord::Base
3
- attr_accessible :salutation_type, :city, :postal_code, :state, :street_1, :street_2
3
+ attr_accessible :city, :postal_code, :state, :street_1, :street_2
4
4
  has_many :invitations
5
5
  has_many :members
6
6
  has_many :people, :through => :members
7
7
 
8
- validates :salutation_type, :presence => true
9
-
10
8
  include SalutationMixin
11
9
 
12
10
  def family
@@ -4,9 +4,8 @@ module Rsvp
4
4
  belongs_to :family
5
5
  has_many :responses
6
6
 
7
- validates :salutation_type, :presence => true
8
7
  validates :rsvp_code, :presence => true, :uniqueness => true, :length => { is: 7 }
9
- validates :total_invited, :inclusion => 1..10
8
+ validates :total_invited, :presence => true, :inclusion => 1..10
10
9
 
11
10
  include SalutationMixin
12
11
 
@@ -4,6 +4,7 @@ module Rsvp
4
4
  has_many :memberships, :class_name => "Member"
5
5
  has_many :families, :through => :memberships
6
6
 
7
+ validates :gender_type, :presence => true
7
8
  validates :first_name, :presence => true
8
9
  validates :last_name, :presence => true
9
10
 
@@ -15,5 +16,13 @@ module Rsvp
15
16
  def self.adult_females
16
17
  where("gender_type = ?", Gender::AdultFemale.to_s)
17
18
  end
19
+
20
+ def gender_type=(klass)
21
+ write_attribute(:gender_type, klass.to_s)
22
+ end
23
+
24
+ def gender_type
25
+ read_attribute(:gender_type).try(:constantize)
26
+ end
18
27
  end
19
28
  end
@@ -4,7 +4,7 @@ module Rsvp
4
4
  family.people.adult_males.first
5
5
  end
6
6
  def template
7
- "Mr. and Mrs. [[male__first_name]] [[male__last_name]] and family"
7
+ "Mr. and Mrs. [[male__first_name]] [[male__last_name]] and Family"
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Rsvp
4
4
  family.people.adult_females.first
5
5
  end
6
6
  def template
7
- "Ms. [[female__first_name]] [[female__last_name]] and guest"
7
+ "Ms. [[female__first_name]] [[female__last_name]] and Guest"
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Rsvp
4
4
  family.people.adult_males.first
5
5
  end
6
6
  def template
7
- "Mr. [[male__first_name]] [[male__last_name]] and guest"
7
+ "Mr. [[male__first_name]] [[male__last_name]] and Guest"
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Rsvp
4
4
  family.people.adult_females.first
5
5
  end
6
6
  def template
7
- "Mrs. [[female__first_name]] [[female__last_name]] and family"
7
+ "Mrs. [[female__first_name]] [[female__last_name]] and Family"
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Rsvp
4
4
  family.people.adult_males.first
5
5
  end
6
6
  def template
7
- "Mr. [[male__first_name]] [[male__last_name]] and family"
7
+ "Mr. [[male__first_name]] [[male__last_name]] and Family"
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,13 @@
1
1
  module Rsvp
2
2
  module SalutationMixin
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ attr_accessible :salutation_type, :salutation
6
+ after_save :generate_salutation
7
+
8
+ validates :salutation_type, :presence => true
9
+ end
10
+
3
11
  def salutation_type=(klass)
4
12
  write_attribute(:salutation_type, klass.to_s)
5
13
  end
@@ -8,8 +16,16 @@ module Rsvp
8
16
  read_attribute(:salutation_type).try(:constantize)
9
17
  end
10
18
 
11
- def salutation
12
- salutation_type.try(:new, family)
19
+ def generate_salutation
20
+ salutation = read_attribute(:salutation)
21
+ if salutation.blank? && salutation_type.present?
22
+ begin
23
+ write_attribute(:salutation, salutation_type.try(:new, family).to_s)
24
+ self.save(callbacks: false)
25
+ rescue
26
+ # Trap exceptions thrown due to incomplete data structures
27
+ end
28
+ end
13
29
  end
14
30
  end
15
31
  end
@@ -2,6 +2,7 @@ class CreateRsvpFamilies < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :rsvp_families do |t|
4
4
  t.string :salutation_type, :limit => 50
5
+ t.string :salutation
5
6
  t.string :street_1, :limit => 75
6
7
  t.string :street_2, :limit => 75
7
8
  t.string :city, :limit => 50
@@ -3,6 +3,7 @@ class CreateRsvpInvitations < ActiveRecord::Migration
3
3
  create_table :rsvp_invitations do |t|
4
4
  t.integer :family_id
5
5
  t.string :salutation_type, :limit => 50
6
+ t.string :salutation
6
7
  t.string :rsvp_code, :limit => 20
7
8
  t.integer :total_invited
8
9
 
data/lib/rsvp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rsvp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsvp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ricard