concerned 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -64,6 +64,18 @@ FixtureUser.my_shared_concerns # => [:caching]
64
64
  FixtureUser.all_my_shared_concerns # => [:scopes, :validations, :caching]
65
65
  ```
66
66
 
67
+ You can even include concerns from another scope
68
+
69
+ ```ruby
70
+ class FixtureUserFor
71
+ include Concerned
72
+ include_concerns :scopes, :validations, for: 'FixtureUser'
73
+ include_shared_concerns :caching
74
+ end
75
+ ```
76
+
77
+ Will include the `FixtureUser::Scopes` and `FixtureUser::Validations` into `FixtureUserFor` :)
78
+
67
79
  ## Global config
68
80
 
69
81
  You can use the `Concerned.extend_enable!` to let the concern helpers also attempt to extend the host module/class with the ClassMethods module of the concerns module (if such exists). Disable it by using: `Concerned.extend_disable!`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/concerned.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "concerned"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2012-05-31"
12
+ s.date = "2012-09-18"
13
13
  s.description = "Makes it easy to apply the concerns pattern in any Ruby context"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "lib/concerned.rb",
30
30
  "lib/concerned/module_ext.rb",
31
31
  "spec/concerned_spec.rb",
32
+ "spec/fixture_user/foo.rb",
32
33
  "spec/fixture_user/scopes.rb",
33
34
  "spec/fixture_user/validations.rb",
34
35
  "spec/fixture_user_no_meta/scopes.rb",
@@ -17,10 +17,13 @@ class Module
17
17
 
18
18
  def include_concerns(*concerns)
19
19
  options = concerns.extract_options!
20
+ scope_name = options[:for] ? options[:for] : name
20
21
  concerns.flatten.each do |concern|
21
22
  next if concern.blank?
22
- require_concern name, concern
23
- concern_ns = [name, concern.to_s.camelize].join('::')
23
+ require_concern scope_name, concern
24
+
25
+ concern_ns ||= [scope_name.to_s.camelize, concern.to_s.camelize].join('::')
26
+
24
27
  self.send :include, concern_ns.constantize
25
28
 
26
29
  if Concerned.extend_enabled?
@@ -22,6 +22,17 @@ class FixtureUserNoMeta
22
22
  include_concerns :validations
23
23
  end
24
24
 
25
+ class FixtureUserFor
26
+ include_concerns :foo, for: 'fixture_user'
27
+ end
28
+
29
+ describe "Concerned" do
30
+ describe "using :for" do
31
+ it 'should include Foo module' do
32
+ FixtureUserFor.new.should respond_to(:foo)
33
+ end
34
+ end
35
+ end
25
36
 
26
37
  describe "Concerned" do
27
38
  describe "no meta" do
@@ -0,0 +1,6 @@
1
+ class FixtureUser
2
+ module Foo
3
+ def foo
4
+ end
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concerned
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-31 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -111,6 +111,7 @@ files:
111
111
  - lib/concerned.rb
112
112
  - lib/concerned/module_ext.rb
113
113
  - spec/concerned_spec.rb
114
+ - spec/fixture_user/foo.rb
114
115
  - spec/fixture_user/scopes.rb
115
116
  - spec/fixture_user/validations.rb
116
117
  - spec/fixture_user_no_meta/scopes.rb
@@ -133,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
134
  version: '0'
134
135
  segments:
135
136
  - 0
136
- hash: -974900177566873517
137
+ hash: 4276078573137133758
137
138
  required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  none: false
139
140
  requirements: