Skip to content

Commit 322b702

Browse files
committed
Allow configurations as item types in collections
1 parent 451cb7b commit 322b702

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

lib/alchemy/configuration.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
require "alchemy/configuration/boolean_option"
77
require "alchemy/configuration/collection_option"
8+
require "alchemy/configuration/configuration_option"
89
require "alchemy/configuration/class_option"
910
require "alchemy/configuration/class_set_option"
1011
require "alchemy/configuration/integer_option"
1112
require "alchemy/configuration/regexp_option"
1213
require "alchemy/configuration/string_option"
13-
require "alchemy/configuration/collection_option"
1414

1515
module Alchemy
1616
class Configuration
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
# frozen_string_literal: true
4+
5+
require "alchemy/configuration/base_option"
6+
7+
module Alchemy
8+
class Configuration
9+
class ConfigurationOption < BaseOption
10+
def self.value_class
11+
Alchemy::Configuration
12+
end
13+
end
14+
end
15+
end

spec/libraries/alchemy/configuration/collection_option_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,21 @@
4040
it { is_expected.to contain_exactly(String) }
4141
end
4242
end
43+
44+
context "with an array of configurations" do
45+
let(:collection_class) { Array }
46+
let(:item_type) { :configuration }
47+
let(:value) do
48+
[
49+
Alchemy::Configurations::Sitemap.new(
50+
show_root: true,
51+
show_flag: false
52+
)
53+
]
54+
end
55+
56+
it "contains configurations" do
57+
expect(subject.value.first.show_root).to be true
58+
end
59+
end
4360
end

0 commit comments

Comments
 (0)