blue_print 1.1.2 → 1.2.0
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dac49db02726e3eb81813a54cc21dcb925c0fdc7
|
4
|
+
data.tar.gz: 94fa55109ad2e66a624696f8c71b6c135e95cc79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e70beb4dc39b6ac98e9e4c8400e7c531b116b3a66bae91d7d6514a3c4a75cb66eabf46ff0c6d4dcdbce2a066caad103c8c5aa5a28ed2a8e827533b9514f453ee
|
7
|
+
data.tar.gz: 15922fb424ff0b7dd63e423b6677fca54e565c734f179a975864a33a53dd4588d6af9597274a5fb134f329ae8e31a7861916f5c3561da9cc4746302ff90d34c2
|
data/lib/blue_print/context.rb
CHANGED
@@ -3,17 +3,11 @@ require 'blue_print'
|
|
3
3
|
require 'blue_print/active_if'
|
4
4
|
|
5
5
|
class BluePrint::Context
|
6
|
-
NAMED_CONTEXT_MAP = {}
|
7
|
-
|
8
|
-
def self.inherited(klass)
|
9
|
-
NAMED_CONTEXT_MAP[klass.context_name] = klass
|
10
|
-
end
|
11
|
-
|
12
6
|
def self.resolve(name)
|
13
7
|
if name.respond_to?(:active?)
|
14
8
|
return name
|
15
9
|
else
|
16
|
-
|
10
|
+
name.to_s.classify.sub(/(Context)?$/, 'Context').safe_constantize
|
17
11
|
end
|
18
12
|
end
|
19
13
|
|
data/lib/blue_print/version.rb
CHANGED
@@ -9,7 +9,7 @@ class <%= class_name %>Context < <%= parent_class_name.classify %>
|
|
9
9
|
<%- end -%>
|
10
10
|
|
11
11
|
<%- models.each_pair do |model, roles| -%>
|
12
|
-
|
12
|
+
cast ::<%= model %>, as: [<%= roles.join(', ') %>]
|
13
13
|
<%- end -%>
|
14
14
|
end
|
15
15
|
<% end -%>
|
@@ -1,13 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
class SpecContext < BluePrint::Context
|
4
|
+
end
|
5
|
+
|
3
6
|
describe BluePrint::Context do
|
4
|
-
subject(:context) {
|
7
|
+
subject(:context) { SpecContext }
|
8
|
+
|
9
|
+
after do
|
10
|
+
context.active_ifs.clear
|
11
|
+
end
|
5
12
|
|
6
13
|
describe '#resolve' do
|
7
14
|
subject { BluePrint::Context.resolve(name) }
|
8
15
|
|
9
|
-
context 'with
|
10
|
-
let(:name) {
|
16
|
+
context 'with :spec' do
|
17
|
+
let(:name) { :spec }
|
11
18
|
|
12
19
|
it { should eq(context) }
|
13
20
|
end
|
@@ -36,7 +43,7 @@ describe BluePrint::Context do
|
|
36
43
|
describe '#context_name' do
|
37
44
|
subject(:context_name) { context.context_name }
|
38
45
|
|
39
|
-
it { should eq(:
|
46
|
+
it { should eq(:spec_context) }
|
40
47
|
end
|
41
48
|
|
42
49
|
describe '#active?' do
|
@@ -117,6 +124,7 @@ describe BluePrint::Context do
|
|
117
124
|
|
118
125
|
before do
|
119
126
|
context.cast(klass, as: role)
|
127
|
+
context.instance_variable_set(:@acted, false)
|
120
128
|
context.action!
|
121
129
|
end
|
122
130
|
|
@@ -62,7 +62,7 @@ describe Rails::Generators::BluePrintGenerator do
|
|
62
62
|
expect(destination_root).to(have_structure do
|
63
63
|
directory 'app/blue_prints' do
|
64
64
|
file 'staff_context.rb' do
|
65
|
-
contains '
|
65
|
+
contains 'cast ::User, as: [Staff, Customer]'
|
66
66
|
end
|
67
67
|
|
68
68
|
directory 'staff_context' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blue_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Kusano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|