Module: Stimulizer
- Extended by:
- Dry::Configurable
- Defined in:
- lib/stimulizer.rb,
lib/stimulizer/version.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Error
Constant Summary
collapse
- VERSION =
"0.2.2"
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(klass) ⇒ Object
16
17
18
|
# File 'lib/stimulizer.rb', line 16
def self.included(klass)
klass.extend(ClassMethods)
end
|
Instance Method Details
#stimulus(*args) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/stimulizer.rb', line 48
def stimulus(*args)
output = stimulus_hash(*args)
return output if _stimulizer_opts[:output] == :hash
output.to_a
.map { |k, v| %(#{k.to_s.strip}="#{v.to_s.strip}") }
.join(" ")
.squish
.strip
.html_safe
end
|
#stimulus_controller ⇒ Object
32
33
34
|
# File 'lib/stimulizer.rb', line 32
def stimulus_controller
build_stimulus_controller
end
|
#stimulus_hash(*args) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/stimulizer.rb', line 36
def stimulus_hash(*args)
if args.size == 1 && !args.first.is_a?(Hash)
build_stimulus_hash(args.first)
elsif args.size == 1 && args.first.is_a?(Hash)
build_stimulus_hash(**args.first)
elsif args.size == 2 && args[1..].all? { |a| a.is_a?(Hash) }
build_stimulus_hash(args[0], **args[1..].first)
else
raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 1..2)"
end
end
|