delegate_all_for 0.0.8 → 0.0.9

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,9 +1,9 @@
1
- # DelegateAllFor
1
+ # delegate_all_for
2
2
 
3
- Inspired by the ["Delegating Your
4
- Attributes"](http://killswitchcollective.com/articles/21_delegating_your_attributes)
5
- article this gem allows for easy [delegation](http://apidock.com/rails/Module/delegate) of all columns of an ActiveRecord association, including
6
- the getter, setter, and predicate for each column.
3
+ The primary driver for creating this gem was to create an easy way to accomplish the
4
+ [Multiple Table Inheritance](http://techspry.com/ruby_and_rails/multiple-table-inheritance-in-rails-3/)
5
+ pattern in active record. delegate_all_for allows for easy [delegation](http://apidock.com/rails/Module/delegate)
6
+ of all the columns of an ActiveRecord association, including the getter, setter, and predicate for each column.
7
7
 
8
8
  ## Usage
9
9
 
@@ -11,7 +11,7 @@ the getter, setter, and predicate for each column.
11
11
  class Parent < ActiveRecord::Base
12
12
  has_one :child
13
13
  # columns: name
14
- delegate_all_for :child, except: [:sort], also_include: [:extra_method]
14
+ delegate_all_for :child, except: [:sort], also_include: [:extra_method], allow_nil: true
15
15
  end
16
16
 
17
17
  class Child < ActiveRecord::Base
@@ -49,3 +49,7 @@ Or install it yourself as:
49
49
  3. Commit your changes (`git commit -am 'Added some feature'`)
50
50
  4. Push to the branch (`git push origin my-new-feature`)
51
51
  5. Create new Pull Request
52
+
53
+ ## Credits
54
+
55
+ * Inspiration for how to do it came from [Delegating Your Attributes](http://killswitchcollective.com/articles/21_delegating_your_attributes)
@@ -21,6 +21,7 @@ module DelegateAllFor
21
21
  # [:allow_nil]
22
22
  # Allows accessor to be nil. See the <tt>delegate</tt> documentation.
23
23
  def delegate_all_for(*attr_names)
24
+ return unless self.table_exists?
24
25
  options = { except: [], also_include: [], prefix: false, allow_nil: false }
25
26
  options.update(attr_names.extract_options!)
26
27
  options.assert_valid_keys(:except, :also_include, :prefix, :allow_nil)
@@ -1,3 +1,3 @@
1
1
  module DelegateAllFor
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jason Rust
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-05-09 00:00:00 -07:00
17
+ date: 2013-03-13 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency