acts_as 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10b787576f55530c920e1d5fd6e448dac4c469d8
4
- data.tar.gz: bc8a0ff7ed25ca4c478013dca369d1d86e895784
3
+ metadata.gz: 4ba14af8fa70697f7fb73d98603803dba5d45960
4
+ data.tar.gz: af54cf74f118c481339507a63edc61e11583ea24
5
5
  SHA512:
6
- metadata.gz: b7b75591316fa01a115948ceb8d611be36e6a8e9ab725e8d1bfafdd91ab70085e4bfc98badd7ebda34242180e13492ba8b52c325c0ffe3b093052d93294cbe6a
7
- data.tar.gz: f8c35caa20e70ee99ca90483ce1f2d03714c4e83bbbd79ee6b12381d3f08d1374b5d669e5b976031fae6e1fa9d6b5318567b4c8ba74998de29cfbb06849f7b49
6
+ metadata.gz: e0749e06b1dd10faff18141970375ff3311940f50ba599cfaae50b0cbd15f5ce9e92ba976e73931a834a923d24aeb78c9c9cea0c17b5e8aaaec002f052b91df6
7
+ data.tar.gz: 23d6dbd8a70960c27ba5019c1fa14dc867c89103ea3112010775df02afaab10539829dd8e059f7fe9e5f18f175743b36e863aa23772d7f4cc2b3235c5722bd05
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # ActsAs
2
2
 
3
- ActiveRecord extension for easy belongs_to composition and delegation
3
+ Essentially, this is just a wrapper around the usual [ActiveRecord::Assocations::Classmethods#belongs_to](http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-belongs_to) that inlines delegation of all active_record attribute setters/getters/helpers (with prefix support) and any additional methods, thus serving as a proxy for another table and model.
4
4
 
5
5
  * Transparently write to multiple tables from one active record model by proxying attributes and their methods through a second model.
6
6
  * Easily extract a new table from an existing table, but keep the existing API intact without breaking any consumers.
7
7
  * When using STI to maintain easy joins, this is an easy way to proxy unique child attributes through to another table for that child
8
+ * Can help you enforce the [Law of Demeter](http://en.wikipedia.org/wiki/Law_of_Demeter)
8
9
 
9
10
  This is designed for any belongs_to relationship where lifecycles are tightly coupled and proxying of attribute helpers from belongs_to -> has_one is desired.
10
11
 
@@ -16,14 +17,10 @@ Add this line to your application's Gemfile:
16
17
 
17
18
  gem 'acts_as'
18
19
 
19
- And then execute:
20
+ And then:
20
21
 
21
22
  $ bundle
22
23
 
23
- Or install it yourself as:
24
-
25
- $ gem install acts_as
26
-
27
24
  ## Usage
28
25
 
29
26
  ```ruby
@@ -93,7 +90,8 @@ How does the active record join hash-parsing stuff work? EX-
93
90
  Rebel.joins(:clan).where(clan: {cool: true)
94
91
 
95
92
  Can we make this work for ruby-sql autojoins? Is that even a good idea?
96
- Rebel.where(cool: true) #auto-joins :clan
93
+
94
+ Rebel.where(cool: true) #auto-joins :clan and queries clans table
97
95
 
98
96
  ## Contributing
99
97
 
@@ -1,3 +1,3 @@
1
1
  module ActsAs
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/acts_as.rb CHANGED
@@ -24,7 +24,7 @@ module ActsAs
24
24
  belongs_to(association, **options.merge(autosave: true))
25
25
  define_method(association) { |*args| super(*args) || send("build_#{association}", *args) }
26
26
 
27
- if (association_class = new.send(association).class).table_exists?
27
+ if (association_class = (options[:class_name] || association).to_s.camelcase.constantize).table_exists?
28
28
  whitelist_and_delegate_fields(association_class, association, prefix, with)
29
29
  override_method_missing
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - winfred