inherits_many 0.0.1 → 0.0.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.
data/README.md CHANGED
@@ -1,7 +1,16 @@
1
- inherits_many
2
- =============
1
+ # inherits_many
3
2
 
4
- An individual restaurant can have many menu items, but a restaurant that belongs to a chain inherits all it's menu items from the chain it belongs to.
3
+ ## Summary
4
+ Allow many-to-many relationships to inherit associated objects from a parent object's `has_many` association.
5
+
6
+ ## Installation
7
+ Add the following to your `Gemfile`:
8
+
9
+ gem 'inherits_many'
10
+
11
+ ## Usage Example
12
+
13
+ An individual restaurant can have many menu items, but a restaurant that belongs to a chain inherits all it's menu items from the chain it belongs to. The behaviors we want include:
5
14
 
6
15
  * When a restaurant joins a chain, it gets a copy of all the menu items from that chain.
7
16
  * When a restaurant leaves a chain, all those menu items go away.
@@ -20,13 +29,22 @@ The ActiveRecord associations and `inherits_many` definition look like this:
20
29
  has_many :restaurants, through: :restaurant_menu_items
21
30
  belongs_to :chain
22
31
 
32
+ # Syntax for this gem.
23
33
  passes_on_to :restaurants, of: :chain
34
+
24
35
  end
25
36
 
26
37
  class Restaurant < ActiveRecord::Base
27
38
  has_many :restaurant_menu_items
28
39
  has_many :menu_items, through: :restaurant_menu_items
29
40
  belongs_to :chain
30
-
41
+
42
+ # Syntax for this gem.
31
43
  inherits_many :menu_items, from: :chain
44
+
32
45
  end
46
+
47
+ class RestaurantMenuItem < ActiveRecord::Base
48
+ belongs_to :restaurant
49
+ belongs_to :menu_item
50
+ end
@@ -1,3 +1,3 @@
1
1
  module InheritsMany
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/provisioner.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Andrew Culver"]
9
9
  s.email = ["andrew.culver@gmail.com"]
10
10
  s.homepage = "http://github.com/wearetitans/inherits_many"
11
- s.summary = %q{Allow has_many relationships to inherit associated objects from a parent object's has_many association.}
11
+ s.summary = %q{Allow many-to-many relationships to inherit associated objects from a parent object's has_many association.}
12
12
  s.description = %q{Example: "If a restaurant can have many menu items and a chain has many menu items, ensure all restaurants have the menu items of the chain they belong to."}
13
13
 
14
14
  s.rubyforge_project = "inherits_many"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inherits_many
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70174225082380 !ruby/object:Gem::Requirement
16
+ requirement: &70124367390840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70174225082380
24
+ version_requirements: *70124367390840
25
25
  description: ! 'Example: "If a restaurant can have many menu items and a chain has
26
26
  many menu items, ensure all restaurants have the menu items of the chain they belong
27
27
  to."'
@@ -61,6 +61,6 @@ rubyforge_project: inherits_many
61
61
  rubygems_version: 1.8.15
62
62
  signing_key:
63
63
  specification_version: 3
64
- summary: Allow has_many relationships to inherit associated objects from a parent
64
+ summary: Allow many-to-many relationships to inherit associated objects from a parent
65
65
  object's has_many association.
66
66
  test_files: []