has_many_emails 0.3.2 → 0.3.3

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.
@@ -1,6 +1,6 @@
1
1
  = has_many_emails
2
2
 
3
- Add multiply emails to the +User+ model without changing the +email+ attribute behaviour.
3
+ Add multiply emails to the addressee's model without changing the +email+ attribute behaviour.
4
4
 
5
5
  == Installation
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_many_emails}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Danil Pismenny"]
@@ -2,23 +2,23 @@ class <%= migration_name %> < ActiveRecord::Migration
2
2
 
3
3
  def self.up
4
4
  create_table :<%= email_address_table_name %> do |t|
5
- t.integer :owner_id, :null => false
6
- t.string :owner_type, :null => false
5
+ t.integer :addressee_id, :null => false
6
+ t.string :addressee_type, :null => false
7
7
  t.string :email, :null => false
8
8
  # t.boolean :is_main, :null => false, :default=>false
9
9
 
10
10
  t.timestamps
11
11
  end
12
12
 
13
- add_index :<%= email_address_table_name %>, [:owner_id, :owner_type, :email], :unique=>true
13
+ add_index :<%= email_address_table_name %>, [:addressee_id, :addressee_type, :email], :unique=>true, :name=>:index_<%= email_address_table_name %>_addressee_id
14
14
  add_index :<%= email_address_table_name %>, :email
15
15
 
16
16
 
17
17
  <% models_with_emails.each do |model| %>
18
18
  if <%= model %>.column_names.include? 'email'
19
19
  raise "PROBLEM! <%= model %> does not have 'has_many_emails'. Insert it before usage." unless <%= model %>.respond_to? :has_many_emails
20
- <%= model %>.all.each do |owner|
21
- owner.add_email owner.attributes['email']
20
+ <%= model %>.all.each do |addressee|
21
+ addressee.add_email addressee.attributes['email']
22
22
  end
23
23
  end
24
24
  <% end %>
@@ -13,7 +13,7 @@ module HasManyEmails
13
13
  def has_many_emails
14
14
  class_eval <<-EOV
15
15
 
16
- has_many :email_addresses, :dependent=>:destroy, :class_name => 'HasManyEmails::EmailAddress'
16
+ has_many :email_addresses, :dependent=>:destroy, :class_name => 'HasManyEmails::EmailAddress', :as => :addressee
17
17
 
18
18
  validate :validate_email_addresses
19
19
 
@@ -4,7 +4,7 @@ module HasManyEmails
4
4
  module ClassMethods
5
5
 
6
6
  def find_by_email( email )
7
- address = HasManyEmails::EmailAddress.find_by_email( email.downcase ) and address.owner
7
+ address = HasManyEmails::EmailAddress.find_by_email( email.downcase ) and address.addressee
8
8
  end
9
9
 
10
10
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  class HasManyEmails::EmailAddress < ActiveRecord::Base
3
- belongs_to :owner, :polymorphic => true
3
+ belongs_to :addressee, :polymorphic => true
4
4
 
5
5
  normalize_attributes :email
6
6
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_many_emails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Danil Pismenny