is_association 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ is_association
2
+ ==============
3
+
4
+ Patches ActiveRecord::Base to expose a method is_association? The method will return true for all associations like has_one, has_many and belongs_to while returning false for regular attributes on the table.
@@ -1,7 +1,7 @@
1
1
  class ActiveRecord::Base
2
2
  def is_association? relation
3
3
  begin
4
- self.association(relation)
4
+ self.association(relation.to_sym)
5
5
  rescue NoMethodError
6
6
  return false
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module IsAssociation
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -39,6 +39,11 @@ describe 'ActiveRecord::Base', %q{
39
39
  post.is_association?(:comments).should == true
40
40
  end
41
41
 
42
+ it 'responds with "true" when relation is as string' do
43
+ post = Post.new
44
+ post.is_association?('comments').should == true
45
+ end
46
+
42
47
  it 'responds with "false" when relation is not an association' do
43
48
  post = Post.new
44
49
  post.is_association?(:name).should == false
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is_association
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alain M. Lafon
@@ -32,11 +32,11 @@ files:
32
32
  - .rvmrc
33
33
  - Gemfile
34
34
  - Gemfile.lock
35
+ - README.md
35
36
  - Rakefile
36
37
  - is_association.gemspec
37
38
  - lib/is_association.rb
38
39
  - lib/is_association/version.rb
39
- - spec/.is_association_spec.rb.swp
40
40
  - spec/is_association_spec.rb
41
41
  - spec/spec_helper.rb
42
42
  homepage: ""