ownable 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,11 @@ Ownable exposes an instance method on ActiveRecord objects that declare themselv
11
11
  For example, assume the associations:
12
12
 
13
13
  User has_many Orders has_one Invoice has_many Payments
14
-
14
+
15
+ or in the opposite direction:
16
+
17
+ Payments belongs_to Invoice belongs_to Orders belongs_to User
18
+
15
19
  Determine if a User "owns" a particular Payment object
16
20
 
17
21
  Rather than manually defining and then checking the association between User and Payment like:
@@ -20,6 +24,18 @@ Determine if a User "owns" a particular Payment object
20
24
  you can use Ownable for a much shorter and simpler syntax:
21
25
  @payment.owned_by? current_user # => true/false
22
26
 
27
+ This gem is most helpful when many association steps exist between Models, such as:
28
+
29
+ A belongs_to B belongs_to ... belongs_to Y belongs_to Z
30
+
31
+ And the ownership check can be written short hand via Ownable as:
32
+
33
+ @a.owned_by? @z # => true/false
34
+
35
+ or
36
+
37
+ @a.belongs_to? @z # => true/false
38
+
23
39
  ## INSTALLATION
24
40
 
25
41
  Ownable is currently available only in Gem form and requires version >= 3.0 of Rails.
data/Rakefile CHANGED
File without changes
File without changes
@@ -11,7 +11,7 @@ module Ownable
11
11
  def acts_as_ownable(options = {})
12
12
  cattr_accessor :ownable_through
13
13
 
14
- self.ownable_through = options[:through] || [':user']
14
+ self.ownable_through = options[:through] || ['user']
15
15
  end
16
16
 
17
17
  end #ClassMethods
@@ -38,9 +38,9 @@ module Ownable
38
38
 
39
39
  self.ownable_through.each do |class_name|
40
40
  begin
41
- owner = owner.send class_name
41
+ owner = owner.send class_name
42
42
  rescue
43
- owner = nil
43
+ owner = nil
44
44
  end
45
45
  end
46
46
 
File without changes
@@ -1,3 +1,3 @@
1
1
  module Ownable
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
File without changes
metadata CHANGED
@@ -1,12 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ownable
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
4
+ version: 0.2.1
10
5
  platform: ruby
11
6
  authors:
12
7
  - David Gonzalez
@@ -14,24 +9,19 @@ autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
11
 
17
- date: 2010-10-04 00:00:00 -04:00
12
+ date: 2010-10-31 00:00:00 -04:00
18
13
  default_executable:
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: rails
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
25
20
  requirements:
26
21
  - - ~>
27
22
  - !ruby/object:Gem::Version
28
- segments:
29
- - 3
30
- - 0
31
- - 0
32
23
  version: 3.0.0
33
- type: :runtime
34
- version_requirements: *id001
24
+ version:
35
25
  description: Model ownership with Rails 3
36
26
  email:
37
27
  - davidjgonzalez@gmail.com
@@ -59,27 +49,21 @@ rdoc_options: []
59
49
  require_paths:
60
50
  - lib
61
51
  required_ruby_version: !ruby/object:Gem::Requirement
62
- none: false
63
52
  requirements:
64
53
  - - ">="
65
54
  - !ruby/object:Gem::Version
66
- segments:
67
- - 0
68
55
  version: "0"
56
+ version:
69
57
  required_rubygems_version: !ruby/object:Gem::Requirement
70
- none: false
71
58
  requirements:
72
59
  - - ">="
73
60
  - !ruby/object:Gem::Version
74
- segments:
75
- - 1
76
- - 3
77
- - 6
78
61
  version: 1.3.6
62
+ version:
79
63
  requirements: []
80
64
 
81
65
  rubyforge_project:
82
- rubygems_version: 1.3.7
66
+ rubygems_version: 1.3.5
83
67
  signing_key:
84
68
  specification_version: 3
85
69
  summary: Model ownership with Rails 3