Class: ActionView::Storybook::Dsl::ControlsDsl
- Inherits:
-
Object
- Object
- ActionView::Storybook::Dsl::ControlsDsl
show all
- Defined in:
- lib/action_view/storybook/dsl/controls_dsl.rb
Constant Summary
collapse
- Controls =
ActionView::Storybook::Controls
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#array(param, value, separator = ",", 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
-
#date(param, value, name: nil) ⇒ Object
-
#initialize(story_config) ⇒ ControlsDsl
constructor
A new instance of ControlsDsl.
-
#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
Constructor Details
#initialize(story_config) ⇒ ControlsDsl
Returns a new instance of ControlsDsl.
9
10
11
12
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 9
def initialize(story_config)
@story_config = story_config
@controls = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 74
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 Attribute Details
#controls ⇒ Object
Returns the value of attribute controls.
7
8
9
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 7
def controls
@controls
end
|
Instance Method Details
#array(param, value, separator = ",", name: nil) ⇒ Object
62
63
64
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 62
def array(param, value, separator = ",", name: nil)
controls << Controls::ArrayConfig.new(param, value, separator, name: name)
end
|
#boolean(param, value, name: nil) ⇒ Object
18
19
20
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 18
def boolean(param, value, name: nil)
controls << Controls::BooleanConfig.new(param, value, name: name)
end
|
#check(param, options, value, name: nil) ⇒ Object
54
55
56
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 54
def check(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:check, param, options, value, name: name)
end
|
#color(param, value, name: nil, preset_colors: nil) ⇒ Object
30
31
32
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 30
def color(param, value, name: nil, preset_colors: nil)
controls << Controls::ColorConfig.new(param, value, name: name, preset_colors: preset_colors)
end
|
#date(param, value, name: nil) ⇒ Object
66
67
68
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 66
def date(param, value, name: nil)
controls << Controls::DateConfig.new(param, value, name: name)
end
|
#inline_check(param, options, value, name: nil) ⇒ Object
58
59
60
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 58
def inline_check(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:'inline-check', param, options, value, name: name)
end
|
#inline_radio(param, options, value, name: nil) ⇒ Object
50
51
52
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 50
def inline_radio(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:'inline-radio', param, options, value, name: name)
end
|
#multi_select(param, options, value, name: nil) ⇒ Object
42
43
44
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 42
def multi_select(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:'multi-select', param, options, value, name: name)
end
|
#number(param, value, name: nil, min: nil, max: nil, step: nil) ⇒ Object
22
23
24
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 22
def number(param, value, name: nil, min: nil, max: nil, step: nil)
controls << Controls::NumberConfig.new(:number, param, value, name: name, min: min, max: max, step: step)
end
|
#object(param, value, name: nil) ⇒ Object
34
35
36
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 34
def object(param, value, name: nil)
controls << Controls::ObjectConfig.new(param, value, name: name)
end
|
#radio(param, options, value, name: nil) ⇒ Object
46
47
48
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 46
def radio(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:radio, param, options, value, name: name)
end
|
#range(param, value, name: nil, min: nil, max: nil, step: nil) ⇒ Object
26
27
28
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 26
def range(param, value, name: nil, min: nil, max: nil, step: nil)
controls << Controls::NumberConfig.new(:range, param, value, name: name, min: min, max: max, step: step)
end
|
#respond_to_missing?(_method) ⇒ Boolean
70
71
72
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 70
def respond_to_missing?(_method, *)
true
end
|
#select(param, options, value, name: nil) ⇒ Object
38
39
40
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 38
def select(param, options, value, name: nil)
controls << Controls::OptionsConfig.new(:select, param, options, value, name: name)
end
|
#text(param, value, name: nil) ⇒ Object
14
15
16
|
# File 'lib/action_view/storybook/dsl/controls_dsl.rb', line 14
def text(param, value, name: nil)
controls << Controls::TextConfig.new(param, value, name: name)
end
|