Class: ViewComponent::Storybook::Dsl::LegacyControlsDsl
- Inherits:
-
Object
- Object
- ViewComponent::Storybook::Dsl::LegacyControlsDsl
show all
- Defined in:
- lib/view_component/storybook/dsl/legacy_controls_dsl.rb
Constant Summary
collapse
- Controls =
ViewComponent::Storybook::Controls
Instance Method Summary
collapse
-
#array(param, value, _separator = nil, name: nil) ⇒ Object
-
#boolean(param, value, name: nil) ⇒ Object
-
#check(param, options, value, name: nil) ⇒ Object
-
#color(param, value, name: nil, preset_colors: nil) ⇒ Object
-
#controls ⇒ Object
-
#date(param, value, name: nil) ⇒ Object
-
#inline_check(param, options, value, name: nil) ⇒ Object
-
#inline_radio(param, options, value, name: nil) ⇒ Object
-
#method_missing(method, *args) ⇒ Object
-
#multi_select(param, options, value, name: nil) ⇒ Object
-
#number(param, value, name: nil, min: nil, max: nil, step: nil) ⇒ Object
-
#object(param, value, name: nil) ⇒ Object
-
#radio(param, options, value, name: nil) ⇒ Object
-
#range(param, value, name: nil, min: nil, max: nil, step: nil) ⇒ Object
-
#respond_to_missing?(_method) ⇒ Boolean
-
#select(param, options, value, name: nil) ⇒ Object
-
#text(param, value, name: nil) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 71
def method_missing(method, *args)
value = args.first
control_method = case value
when Date
:date
when Array
:array
when Hash
:object
when Numeric
:number
when TrueClass, FalseClass
:boolean
when String
:text
end
if control_method
send(control_method, method, *args)
else
super
end
end
|
Instance Method Details
#array(param, value, _separator = nil, name: nil) ⇒ Object
59
60
61
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 59
def array(param, value, _separator = nil, name: nil)
controls << Controls::ObjectConfig.new(value, param: param, name: name)
end
|
#boolean(param, value, name: nil) ⇒ Object
15
16
17
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 15
def boolean(param, value, name: nil)
controls << Controls::BooleanConfig.new(value, param: param, name: name)
end
|
#check(param, options, value, name: nil) ⇒ Object
51
52
53
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 51
def check(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:check, options, value, param: param, name: name)
end
|
#color(param, value, name: nil, preset_colors: nil) ⇒ Object
27
28
29
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 27
def color(param, value, name: nil, preset_colors: nil)
controls << Controls::ColorConfig.new(value, param: param, name: name, preset_colors: preset_colors)
end
|
#controls ⇒ Object
7
8
9
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 7
def controls
@controls ||= []
end
|
#date(param, value, name: nil) ⇒ Object
63
64
65
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 63
def date(param, value, name: nil)
controls << Controls::DateConfig.new(value, param: param, name: name)
end
|
#inline_check(param, options, value, name: nil) ⇒ Object
55
56
57
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 55
def inline_check(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:'inline-check', options, value, param: param, name: name)
end
|
#inline_radio(param, options, value, name: nil) ⇒ Object
47
48
49
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 47
def inline_radio(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:'inline-radio', options, value, param: param, name: name)
end
|
#multi_select(param, options, value, name: nil) ⇒ Object
39
40
41
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 39
def multi_select(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:'multi-select', options, value, param: param, name: name)
end
|
#number(param, value, name: nil, min: nil, max: nil, step: nil) ⇒ Object
19
20
21
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 19
def number(param, value, name: nil, min: nil, max: nil, step: nil)
controls << Controls::NumberConfig.new(:number, value, param: param, name: name, min: min, max: max, step: step)
end
|
#object(param, value, name: nil) ⇒ Object
31
32
33
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 31
def object(param, value, name: nil)
controls << Controls::ObjectConfig.new(value, param: param, name: name)
end
|
#radio(param, options, value, name: nil) ⇒ Object
43
44
45
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 43
def radio(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:radio, options, value, param: param, name: name)
end
|
#range(param, value, name: nil, min: nil, max: nil, step: nil) ⇒ Object
23
24
25
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 23
def range(param, value, name: nil, min: nil, max: nil, step: nil)
controls << Controls::NumberConfig.new(:range, value, param: param, name: name, min: min, max: max, step: step)
end
|
#respond_to_missing?(_method) ⇒ Boolean
67
68
69
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 67
def respond_to_missing?(_method, *)
true
end
|
#select(param, options, value, name: nil) ⇒ Object
35
36
37
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 35
def select(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:select, options, value, param: param, name: name)
end
|
#text(param, value, name: nil) ⇒ Object
11
12
13
|
# File 'lib/view_component/storybook/dsl/legacy_controls_dsl.rb', line 11
def text(param, value, name: nil)
controls << Controls::TextConfig.new(value, param: param, name: name)
end
|