rsvp 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGE3Njk4MTE2MzEyOGY0MjY5NjE1YzgwN2ZkYWY5MTAwMjMzNzc2Zg==
4
+ NzJjZTZiYWZhYzI4YWI4YjQxMWM3Zjg1ZjE2YWRmOWUwNWFlZjE4Yg==
5
5
  data.tar.gz: !binary |-
6
- MGYwOTU5NDMwYWY5YmE0ZGViODY2NDQ0ZDRiYjQyMmQyYzUwZGI2ZA==
6
+ NjQ1MGVhZjg0ZDJmMjdmNWZhOWRmMmNiMTM3NWM2M2UxM2RjNTU2Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2ZiYzM0YTZhYzNjMzliYTUyNjcwMmFhMzI3MzRkMzJhZDMxZDUzYjgzYzQ2
10
- MjE3ZjUxYTkxYWI5MjFmMTZjMzFhZTEyN2ViNmY0NTdiZDA1YTI5OGQ1NzA5
11
- YmFiYWNiZjdkZGEzZWQ2MjVkOGU2ZjEzNzYzNWQyNzZmNzY1OTk=
9
+ NWM3ZDllNWUzOTRhMWQ1YmRkYzAzOWE1OGVjNzBmNmZlYjI5OTc2OTRkMzBh
10
+ OGYzNzBlYjU3MjJlMDUyNDY2Y2I1ZTVlMmUxNTY2NmU4OWE1MTI1NDQyMGUz
11
+ MGVjM2NmMWY1NTY1MDhhZjI2NGRhMDE1OTM4MDlhZjFkOGQ0ZDI=
12
12
  data.tar.gz: !binary |-
13
- ZTJkNDZiZDc1MzEzNGE2MDFjOGE5Yzg4NGM5YmQzYWE1MDQwMjVhZmJjMWNk
14
- MzdjZWEzODFkNGM4ZWRlZjU2ZjA3ZTk5MzQxMmUxNDNhMDNmMDNkYWI5MDI1
15
- Y2ZhNTZjOGI4OGUzYmU4ZmVkMzA2MGI4YWI2OTJmZjhjZTRkOTM=
13
+ ODU1MTQ4ZTE4MDU4YTAxMDQ4ZDY3ZDVmNzVlNzkzNzkyNzUxOTJhZTFiNDFk
14
+ MTE5MjZiYjJhZDZlZWVhYTVlODE3ZTI5YjhlMDliZDFlN2Y5NTg3YmFhNzkz
15
+ MDViNDNmNWJiZGE2MWZiMGExY2Y4ZTJhYTFiMmU3YTBlOGY2MDg=
@@ -1,9 +1,16 @@
1
1
  module Rsvp
2
2
  class Family < ActiveRecord::Base
3
- attr_accessible :city, :postal_code, :state, :street_1, :street_2
3
+ attr_accessible :salutation_type, :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
- has_one :salutation
7
+
8
+ validates :salutation_type, :presence => true
9
+
10
+ include SalutationMixin
11
+
12
+ def family
13
+ self
14
+ end
8
15
  end
9
16
  end
@@ -1,12 +1,15 @@
1
1
  module Rsvp
2
2
  class Invitation < ActiveRecord::Base
3
- attr_accessible :rsvp_code, :total_invited
3
+ attr_accessible :salutation_type, :rsvp_code, :total_invited
4
4
  belongs_to :family
5
5
  has_many :responses
6
6
 
7
+ validates :salutation_type, :presence => true
7
8
  validates :rsvp_code, :presence => true, :uniqueness => true, :length => { is: 7 }
8
9
  validates :total_invited, :inclusion => 1..10
9
10
 
11
+ include SalutationMixin
12
+
10
13
  def total_invite_options
11
14
  (1..total_invited).to_a
12
15
  end
@@ -1,7 +1,11 @@
1
1
  module Rsvp
2
- class Salutation < ActiveRecord::Base
3
- attr_accessible :type
4
- belongs_to :family
2
+ class Salutation
3
+ attr_accessor :family
4
+
5
+ def initialize(family)
6
+ raise "Salutation class initialization requires a family to be passed." if family.nil?
7
+ @family = family
8
+ end
5
9
 
6
10
  def template
7
11
  raise "Template not implemented in subclass."
@@ -0,0 +1,15 @@
1
+ module Rsvp
2
+ module SalutationMixin
3
+ def salutation_type=(klass)
4
+ write_attribute(:salutation_type, klass.to_s)
5
+ end
6
+
7
+ def salutation_type
8
+ read_attribute(:salutation_type).try(:constantize)
9
+ end
10
+
11
+ def salutation
12
+ salutation_type.try(:new, family)
13
+ end
14
+ end
15
+ end
@@ -6,7 +6,7 @@
6
6
  <% end %>
7
7
  <% end %>
8
8
 
9
- <p>Hi, <%= @invitation.family.salutation %>! Thank you for choosing to RSVP to our special day.</p>
9
+ <p>Hi, <%= @invitation.family.salutation.to_s %>! Thank you for choosing to RSVP to our special day.</p>
10
10
  <p>Will you attend?</p>
11
11
 
12
12
  <ul>
@@ -1,6 +1,7 @@
1
1
  class CreateRsvpFamilies < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :rsvp_families do |t|
4
+ t.string :salutation_type, :limit => 50
4
5
  t.string :street_1, :limit => 75
5
6
  t.string :street_2, :limit => 75
6
7
  t.string :city, :limit => 50
@@ -2,6 +2,7 @@ class CreateRsvpInvitations < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :rsvp_invitations do |t|
4
4
  t.integer :family_id
5
+ t.string :salutation_type, :limit => 50
5
6
  t.string :rsvp_code, :limit => 20
6
7
  t.integer :total_invited
7
8
 
data/lib/rsvp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rsvp
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsvp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ricard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-06 00:00:00.000000000 Z
11
+ date: 2014-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - ~>
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: '1.3'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: '1.3'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: debugger
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +184,7 @@ files:
184
184
  - app/models/rsvp/salutation/widow_and_family.rb
185
185
  - app/models/rsvp/salutation/widower.rb
186
186
  - app/models/rsvp/salutation/widower_and_family.rb
187
+ - app/models/rsvp/salutation_mixin.rb
187
188
  - app/views/layouts/rsvp/application.html.erb
188
189
  - app/views/rsvp/response/_show.html.erb
189
190
  - app/views/rsvp/response/confirmation.html.erb
@@ -197,7 +198,6 @@ files:
197
198
  - db/migrate/20140106042748_create_rsvp_members.rb
198
199
  - db/migrate/20140106042845_create_rsvp_invitations.rb
199
200
  - db/migrate/20140106043014_create_rsvp_responses.rb
200
- - db/migrate/20140106043143_create_rsvp_salutations.rb
201
201
  - lib/generators/rsvp/USAGE
202
202
  - lib/generators/rsvp/views_generator.rb
203
203
  - lib/rsvp.rb
@@ -1,10 +0,0 @@
1
- class CreateRsvpSalutations < ActiveRecord::Migration
2
- def change
3
- create_table :rsvp_salutations do |t|
4
- t.integer :family_id
5
- t.string :type, :limit => 50
6
-
7
- t.timestamps
8
- end
9
- end
10
- end