Class: StimulusTagHelper::StimulusControllerBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/stimulus_tag_helper/stimulus_controller_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier:, template:, tag: nil, **tag_options) ⇒ StimulusControllerBuilder

all the options are tag options of now



12
13
14
15
16
17
# File 'lib/stimulus_tag_helper/stimulus_controller_builder.rb', line 12

def initialize(identifier:, template:, tag: nil, **tag_options)
  @identifier = identifier
  @template = template
  @tag = tag
  @tag_options = tag_options
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



9
10
11
# File 'lib/stimulus_tag_helper/stimulus_controller_builder.rb', line 9

def identifier
  @identifier
end

#tagObject (readonly)

Returns the value of attribute tag.



9
10
11
# File 'lib/stimulus_tag_helper/stimulus_controller_builder.rb', line 9

def tag
  @tag
end

#tag_optionsObject (readonly)

Returns the value of attribute tag_options.



9
10
11
# File 'lib/stimulus_tag_helper/stimulus_controller_builder.rb', line 9

def tag_options
  @tag_options
end

#templateObject (readonly)

Returns the value of attribute template.



9
10
11
# File 'lib/stimulus_tag_helper/stimulus_controller_builder.rb', line 9

def template
  @template
end

Instance Method Details

#attributes(**attributes) ⇒ Object



41
42
43
# File 'lib/stimulus_tag_helper/stimulus_controller_builder.rb', line 41

def attributes(**attributes)
  template.stimulus_attributes(identifier, **attributes)
end

#capture(&block) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/stimulus_tag_helper/stimulus_controller_builder.rb', line 49

def capture(&block)
  return template.capture(self, &block) unless tag

  template.stimulus_controller_tag(identifier, tag: tag, **tag_options) do
    template.capture(self, &block)
  end
end

#properties(**properties) ⇒ Object



45
46
47
# File 'lib/stimulus_tag_helper/stimulus_controller_builder.rb', line 45

def properties(**properties)
  template.stimulus_properties(identifier, **properties)
end