admin_it 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +6 -0
- data/lib/admin_it/context/collection_context.rb +5 -22
- data/lib/admin_it/context/context.rb +13 -34
- data/lib/admin_it/context/show_context.rb +8 -7
- data/lib/admin_it/context/single_context.rb +35 -33
- data/lib/admin_it/context/table_context.rb +18 -11
- data/lib/admin_it/context/tiles_context.rb +14 -14
- data/lib/admin_it/data/active_record.rb +0 -2
- data/lib/admin_it/field/field.rb +95 -23
- data/lib/admin_it/filters/field_filter.rb +4 -0
- data/lib/admin_it/filters/filter.rb +37 -14
- data/lib/admin_it/helpers/table.rb +13 -17
- data/lib/admin_it/resource.rb +58 -115
- data/lib/admin_it/shared.rb +64 -0
- data/lib/admin_it/version.rb +1 -1
- data/lib/admin_it.rb +7 -5
- data/lib/extend_it/array_of.rb +3 -3
- data/lib/extend_it/asserts.rb +5 -3
- data/lib/extend_it/{class.rb → base.rb} +29 -10
- data/lib/extend_it/callbacks.rb +7 -7
- data/lib/extend_it/config.rb +30 -0
- data/lib/extend_it/dsl.rb +223 -64
- data/lib/extend_it/ensures.rb +193 -0
- data/lib/extend_it.rb +1 -1
- data/spec/extend_it/config_spec.rb +52 -0
- data/spec/extend_it/dsl_spec.rb +149 -0
- data/spec/extend_it/ensures_spec.rb +39 -0
- data/spec/lib/context/collection_context_spec.rb +4 -2
- data/spec/lib/context/context_spec.rb +3 -1
- data/spec/lib/context/single_context_spec.rb +3 -2
- data/spec/lib/data/object_spec.rb +2 -2
- data/spec/lib/field_spec.rb +1 -56
- data/spec/lib/resource_spec.rb +1 -13
- data/spec/spec_helper.rb +7 -0
- data/spec/support/example_groups/context_example_group.rb +3 -3
- metadata +14 -11
- data/lib/admin_it/renderable.rb +0 -18
- data/lib/extend_it/refines.rb +0 -6
- data/lib/extend_it/symbolize.rb +0 -39
- data/spec/lib/definitions_spec.rb +0 -171
- data/spec/lib/utils_spec.rb +0 -39
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require File.join %w(extend_it dsl)
|
3
|
+
|
4
|
+
describe ExtendIt::Dsl do
|
5
|
+
let :includer_class do
|
6
|
+
mod = described_class
|
7
|
+
Class.new do
|
8
|
+
include mod
|
9
|
+
attr_accessor :test, :tests
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let :includer_obj do
|
14
|
+
includer_class.new
|
15
|
+
end
|
16
|
+
|
17
|
+
let :dsl_instance do
|
18
|
+
includer_obj.dsl
|
19
|
+
end
|
20
|
+
|
21
|
+
let :dsl_class do
|
22
|
+
mod = described_class
|
23
|
+
Class.new do
|
24
|
+
include mod
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
let :dsl_obj do
|
29
|
+
dsl_class.new
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#dsl_accessor' do
|
33
|
+
it 'creates getter and setter' do
|
34
|
+
includer_class.dsl { dsl_accessor :test }
|
35
|
+
includer_obj.dsl_eval { self.test 10 }
|
36
|
+
expect(includer_obj.test).to eq 10
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'creates getter that with argument works as setter' do
|
40
|
+
includer_class.dsl { dsl_accessor :test }
|
41
|
+
includer_obj.dsl_eval { test(10) }
|
42
|
+
expect(includer_obj.test).to eq 10
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'creates accessors from array' do
|
46
|
+
includer_class.dsl { dsl_accessor :test, ['one', :two], 10 }
|
47
|
+
expect(dsl_instance).to respond_to :test
|
48
|
+
expect(dsl_instance).to respond_to :one
|
49
|
+
expect(dsl_instance).to respond_to :two
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'uses default value' do
|
53
|
+
includer_class.dsl { dsl_accessor :test, default: 10 }
|
54
|
+
expect(includer_obj.dsl.test).to eq 10
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'uses setter to set value if it given' do
|
58
|
+
includer_class.dsl { dsl_accessor(:test) { 10 } }
|
59
|
+
expect(includer_obj.dsl.test).to eq 10
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'evals block in object context with getter if is Dsl' do
|
63
|
+
includer_class.dsl { dsl_accessor :test }
|
64
|
+
dsl_class.dsl { dsl_accessor :child }
|
65
|
+
obj = dsl_obj
|
66
|
+
includer_obj.dsl_eval { test(obj) { child 'test' } }
|
67
|
+
expect(dsl_obj.instance_variable_get(:@child)).to eq 'test'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#dsl_boolean' do
|
72
|
+
it 'creates getter, setter and checker' do
|
73
|
+
includer_class.dsl { dsl_boolean :test }
|
74
|
+
dsl_instance.test = false
|
75
|
+
expect(dsl_instance.test).to be_false
|
76
|
+
expect(dsl_instance.test?).to be_false
|
77
|
+
expect(includer_obj.test).to be_false
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'sets values to true by default' do
|
81
|
+
includer_class.dsl { dsl_boolean :test }
|
82
|
+
expect(includer_obj.dsl.test?).to be_true
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'creates booleans from array' do
|
86
|
+
includer_class.dsl { dsl_boolean :test, ['one', :two], 10 }
|
87
|
+
expect(dsl_instance).to respond_to :test?
|
88
|
+
expect(dsl_instance).to respond_to :one?
|
89
|
+
expect(dsl_instance).to respond_to :two?
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#dsl_block' do
|
94
|
+
it 'creates setter and getter' do
|
95
|
+
block = proc { :test }
|
96
|
+
includer_class.dsl { dsl_block :test }
|
97
|
+
includer_obj.dsl.test(&block)
|
98
|
+
expect(includer_obj.test).to eq block
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#dsl_use_hash' do
|
103
|
+
before do
|
104
|
+
# includer_class.dsl_accessor :fields
|
105
|
+
includer_class.dsl { dsl_use_hash :tests }
|
106
|
+
includer_obj.tests = { one: 1, two: 2, three: 3 }
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'reorders hash' do
|
110
|
+
includer_obj.dsl.use_tests :two, :three, :one
|
111
|
+
expect(includer_obj.tests).to eq(two: 2, three: 3, one: 1)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'recreates hash' do
|
115
|
+
includer_obj.dsl.use_tests :two, :three
|
116
|
+
expect(includer_obj.tests).to eq(two: 2, three: 3)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'excludes hash' do
|
120
|
+
includer_obj.dsl.use_tests :three, :one, :two, except: :one
|
121
|
+
expect(includer_obj.tests).to eq(three: 3, two: 2)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'excludes hash with except only option' do
|
125
|
+
includer_obj.dsl.use_tests except: :one
|
126
|
+
expect(includer_obj.tests).to eq(two: 2, three: 3)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#dsl_hash_of_objects' do
|
131
|
+
it 'creates objects with creator' do
|
132
|
+
objects = { one: Object.new, two: Object.new }
|
133
|
+
includer_class.dsl do
|
134
|
+
dsl_hash_of_objects(:tests) { |name| objects[name] }
|
135
|
+
end
|
136
|
+
includer_obj.dsl.tests :one, :two
|
137
|
+
expect(includer_obj.tests).to eq objects
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'creates objects on demand' do
|
141
|
+
objects = { one: Object.new }
|
142
|
+
demand = Object.new
|
143
|
+
includer_class.dsl { dsl_hash_of_objects(:tests) { |_| demand } }
|
144
|
+
includer_obj.tests = objects
|
145
|
+
includer_obj.dsl.tests :one, :two
|
146
|
+
expect(includer_obj.tests).to eq(objects.merge(two: demand))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require File.join %w(extend_it ensures)
|
3
|
+
|
4
|
+
using ExtendIt::Ensures if ExtendIt.config.use_refines?
|
5
|
+
|
6
|
+
describe ExtendIt::Ensures do
|
7
|
+
describe '#ensure_symbol' do
|
8
|
+
it 'returns self for symbols' do
|
9
|
+
expect(:test.ensure_symbol).to eq :test
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns symbolized string for strings' do
|
13
|
+
expect('test'.ensure_symbol).to eq :test
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns nil for others' do
|
17
|
+
expect([].ensure_symbol).to be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#ensure_symbols' do
|
22
|
+
it 'returns flatten array of symbols for array' do
|
23
|
+
expect([[:some, 'test'], [:of, 0, nil, 'array']].ensure_symbols)
|
24
|
+
.to eq %i(some test of array)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns [self] for symbols' do
|
28
|
+
expect(:test.ensure_symbols).to eq [:test]
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns array with single symbolized string for strings' do
|
32
|
+
expect('test'.ensure_symbols).to eq [:test]
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns [] for non-arrays' do
|
36
|
+
expect(true.ensure_symbols).to eq []
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe AdminIt::CollectionContext do
|
4
|
-
let(:context_class) { described_class.
|
5
|
-
|
4
|
+
let(:context_class) { described_class.create(:test, object_resource) }
|
5
|
+
=begin
|
6
|
+
subject { context_class.new(nil) }
|
6
7
|
|
7
8
|
# class DSL methods
|
8
9
|
it { expect(context_class.collection?).to be_true }
|
@@ -17,4 +18,5 @@ describe AdminIt::CollectionContext do
|
|
17
18
|
subject.entities = arr
|
18
19
|
expect(subject.entities).to be_kind_of Enumerator
|
19
20
|
end
|
21
|
+
=end
|
20
22
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe AdminIt::Context do
|
4
|
-
let(:context_class) { described_class.
|
4
|
+
let(:context_class) { described_class.create(:test, object_resource) }
|
5
|
+
=begin
|
5
6
|
subject { context_class.new }
|
6
7
|
|
7
8
|
# DSL methods
|
@@ -24,5 +25,6 @@ describe AdminIt::Context do
|
|
24
25
|
expect(subject.class.included_modules)
|
25
26
|
.to include AdminIt::ObjectData::Context
|
26
27
|
end
|
28
|
+
=end
|
27
29
|
end
|
28
30
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe AdminIt::SingleContext do
|
4
|
-
let(:context_class) { described_class.
|
5
|
-
|
4
|
+
let(:context_class) { described_class.create(:test, object_resource) }
|
5
|
+
=begin
|
6
6
|
describe 'DSL methods' do
|
7
7
|
subject { context_class }
|
8
8
|
|
@@ -23,4 +23,5 @@ describe AdminIt::SingleContext do
|
|
23
23
|
expect(subject.values).to be_kind_of Hash
|
24
24
|
end
|
25
25
|
end
|
26
|
+
=end
|
26
27
|
end
|
@@ -14,12 +14,12 @@ describe AdminIt::ObjectData::Context do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
xit 'retrieves all fields for ancestors' do
|
18
18
|
fields = object_context.fields(scope: :all)
|
19
19
|
expect(fields.size).to eq 3
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
xit 'reads fields' do
|
23
23
|
single_object_context.entity = object
|
24
24
|
expect(single_object_context.values).to eq r: 'r_value', rw: 'rw_value'
|
25
25
|
end
|
data/spec/lib/field_spec.rb
CHANGED
@@ -1,62 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe AdminIt::Field, type: :context do
|
4
|
-
subject { described_class.
|
4
|
+
subject { described_class.create(:name, object_class) }
|
5
5
|
|
6
|
-
it 'has name reader' do
|
7
|
-
expect(subject.name).to eq :name
|
8
|
-
end
|
9
6
|
|
10
|
-
it 'converts name to symbol' do
|
11
|
-
expect(described_class.new('test', object_class).name).to eq :test
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'has :unknown type by default' do
|
15
|
-
expect(subject.type).to eq :unknown
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'has DSL type setter' do
|
19
|
-
subject.type :string
|
20
|
-
expect(subject.type).to eq :string
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'rejects reads of write-only fields' do
|
24
|
-
f = described_class.new(:name, object_class, readable: false)
|
25
|
-
expect { f.read(Object.new) }.to raise_error AdminIt::FieldReadError
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'rejects writes to read-only fields' do
|
29
|
-
f = described_class.new(:name, object_class, writable: false)
|
30
|
-
expect { f.write(Object.new, 1) }.to raise_error AdminIt::FieldWriteError
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'calls DSL defined reader for read value' do
|
34
|
-
subject.read { |obj| 10 }
|
35
|
-
expect(subject.read(Object.new)).to eq 10
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'calls DSL defined writer for write value' do
|
39
|
-
subject.write { |obj, value| obj[:test] = value }
|
40
|
-
expect(subject.write({}, 10)).to eq test: 10
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'doesn\'t implements value reading' do
|
44
|
-
expect { subject.send(:read_value, Object.new) }
|
45
|
-
.to raise_error NotImplementedError
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'doesn\'t implements value writing' do
|
49
|
-
expect { subject.send(:write_value, Object.new, 'test') }
|
50
|
-
.to raise_error NotImplementedError
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'has #hide' do
|
54
|
-
subject.hide
|
55
|
-
expect(subject.visible?).to be_false
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'has #show' do
|
59
|
-
subject.show
|
60
|
-
expect(subject.visible?).to be_true
|
61
|
-
end
|
62
7
|
end
|
data/spec/lib/resource_spec.rb
CHANGED
@@ -15,25 +15,13 @@ describe AdminIt::Resource do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '#initialize' do
|
18
|
-
it 'checks name to be a symbol' do
|
19
|
-
object_class
|
20
|
-
expect(AdminIt::Utils)
|
21
|
-
.to receive(:assert_symbol_arg!)
|
22
|
-
.with(:object_class, name: 'name')
|
23
|
-
.and_call_original
|
24
|
-
described_class.new(:object_class)
|
25
|
-
end
|
26
18
|
end
|
27
19
|
|
28
20
|
context 'with single context' do
|
29
21
|
before { subject.contexts << single_object_context_class }
|
30
22
|
|
31
|
-
|
23
|
+
xit 'provides hash-like reader for contexts' do
|
32
24
|
expect(subject[:single]).to eq single_object_context_class
|
33
25
|
end
|
34
|
-
|
35
|
-
it 'provides context names' do
|
36
|
-
expect(subject.contexts_names).to eq [:single]
|
37
|
-
end
|
38
26
|
end
|
39
27
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -24,17 +24,17 @@ module ContextExampleGroup
|
|
24
24
|
end
|
25
25
|
|
26
26
|
let(:object_context_class) do
|
27
|
-
AdminIt::Context.
|
27
|
+
AdminIt::Context.create(:object, object_resource)
|
28
28
|
end
|
29
29
|
let(:object_context) { object_context_class.new }
|
30
30
|
|
31
31
|
let(:single_object_context_class) do
|
32
|
-
AdminIt::SingleContext.
|
32
|
+
AdminIt::SingleContext.create(:single, object_resource)
|
33
33
|
end
|
34
34
|
let(:single_object_context) { single_object_context_class.new }
|
35
35
|
|
36
36
|
let(:collection_object_context_class) do
|
37
|
-
AdminIt::CollectionContext.
|
37
|
+
AdminIt::CollectionContext.create(:collection, object_resource)
|
38
38
|
end
|
39
39
|
let(:collection_object_context) { collection_object_context_class.new }
|
40
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admin_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Ovchinnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- ".gitignore"
|
189
189
|
- ".rspec"
|
190
190
|
- ".rubocop.yml"
|
191
|
+
- ".ruby-version"
|
191
192
|
- ".yardopts"
|
192
193
|
- Gemfile
|
193
194
|
- README.md
|
@@ -263,19 +264,22 @@ files:
|
|
263
264
|
- lib/admin_it/helpers/top_menu.rb
|
264
265
|
- lib/admin_it/locales/en.yml
|
265
266
|
- lib/admin_it/locales/ru.yml
|
266
|
-
- lib/admin_it/renderable.rb
|
267
267
|
- lib/admin_it/resource.rb
|
268
|
+
- lib/admin_it/shared.rb
|
268
269
|
- lib/admin_it/utils.rb
|
269
270
|
- lib/admin_it/version.rb
|
270
271
|
- lib/extend_it.rb
|
271
272
|
- lib/extend_it/array_of.rb
|
272
273
|
- lib/extend_it/asserts.rb
|
274
|
+
- lib/extend_it/base.rb
|
273
275
|
- lib/extend_it/callbacks.rb
|
274
276
|
- lib/extend_it/caller.rb
|
275
|
-
- lib/extend_it/
|
277
|
+
- lib/extend_it/config.rb
|
276
278
|
- lib/extend_it/dsl.rb
|
277
|
-
- lib/extend_it/
|
278
|
-
-
|
279
|
+
- lib/extend_it/ensures.rb
|
280
|
+
- spec/extend_it/config_spec.rb
|
281
|
+
- spec/extend_it/dsl_spec.rb
|
282
|
+
- spec/extend_it/ensures_spec.rb
|
279
283
|
- spec/internal/config/database.yml
|
280
284
|
- spec/internal/config/routes.rb
|
281
285
|
- spec/internal/db/combustion_test.sqlite
|
@@ -286,10 +290,8 @@ files:
|
|
286
290
|
- spec/lib/context/context_spec.rb
|
287
291
|
- spec/lib/context/single_context_spec.rb
|
288
292
|
- spec/lib/data/object_spec.rb
|
289
|
-
- spec/lib/definitions_spec.rb
|
290
293
|
- spec/lib/field_spec.rb
|
291
294
|
- spec/lib/resource_spec.rb
|
292
|
-
- spec/lib/utils_spec.rb
|
293
295
|
- spec/spec_helper.rb
|
294
296
|
- spec/support/example_groups/context_example_group.rb
|
295
297
|
- spec/support/shared_examples/context.rb
|
@@ -314,11 +316,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
314
316
|
version: '0'
|
315
317
|
requirements: []
|
316
318
|
rubyforge_project:
|
317
|
-
rubygems_version: 2.2.
|
319
|
+
rubygems_version: 2.2.2
|
318
320
|
signing_key:
|
319
321
|
specification_version: 4
|
320
322
|
summary: Admin interface
|
321
323
|
test_files:
|
324
|
+
- spec/extend_it/config_spec.rb
|
325
|
+
- spec/extend_it/dsl_spec.rb
|
326
|
+
- spec/extend_it/ensures_spec.rb
|
322
327
|
- spec/internal/config/database.yml
|
323
328
|
- spec/internal/config/routes.rb
|
324
329
|
- spec/internal/db/combustion_test.sqlite
|
@@ -329,10 +334,8 @@ test_files:
|
|
329
334
|
- spec/lib/context/context_spec.rb
|
330
335
|
- spec/lib/context/single_context_spec.rb
|
331
336
|
- spec/lib/data/object_spec.rb
|
332
|
-
- spec/lib/definitions_spec.rb
|
333
337
|
- spec/lib/field_spec.rb
|
334
338
|
- spec/lib/resource_spec.rb
|
335
|
-
- spec/lib/utils_spec.rb
|
336
339
|
- spec/spec_helper.rb
|
337
340
|
- spec/support/example_groups/context_example_group.rb
|
338
341
|
- spec/support/shared_examples/context.rb
|
data/lib/admin_it/renderable.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module AdminIt
|
2
|
-
module Renderable
|
3
|
-
def render(entity = nil, instance = nil, &block)
|
4
|
-
if entity.nil? && instance.nil?
|
5
|
-
# method used as setter - just save block
|
6
|
-
@renderer = block if block_given?
|
7
|
-
elsif !@renderer.nil?
|
8
|
-
# method used as event emmiter, call block in instance or caller
|
9
|
-
# context if it present
|
10
|
-
if instance.nil?
|
11
|
-
@renderer.call(entity)
|
12
|
-
else
|
13
|
-
instance.instance_exec(entity, &@renderer)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/extend_it/refines.rb
DELETED
data/lib/extend_it/symbolize.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module ExtendIt
|
2
|
-
module Symbolize
|
3
|
-
refine Object do
|
4
|
-
def symbolize
|
5
|
-
nil
|
6
|
-
end
|
7
|
-
|
8
|
-
def ensure_symbol
|
9
|
-
nil
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
refine String do
|
14
|
-
def symbolize
|
15
|
-
to_sym
|
16
|
-
end
|
17
|
-
|
18
|
-
def ensure_symbol
|
19
|
-
to_sym
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
refine Symbol do
|
24
|
-
def symbolize
|
25
|
-
self
|
26
|
-
end
|
27
|
-
|
28
|
-
def ensure_symbol
|
29
|
-
self
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
refine Array do
|
34
|
-
def ensure_symbols
|
35
|
-
flatten.map { |x| x.ensure_symbol }.compact
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|