Class: Cocooned::Tags::Base
- Inherits:
-
Object
- Object
- Cocooned::Tags::Base
- Includes:
- Deprecated::TagsHelper::DataAttributes, Deprecated::TagsHelper::DefaultLabel, Cocooned::TagsHelper::DataAttributes, Cocooned::TagsHelper::DefaultLabel
- Defined in:
- lib/cocooned/tags/base.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(template, form, **options, &block) ⇒ Base
constructor
A new instance of Base.
- #render(as: :link) ⇒ Object
Constructor Details
#initialize(template, form, **options, &block) ⇒ Base
Returns a new instance of Base.
22 23 24 25 26 27 |
# File 'lib/cocooned/tags/base.rb', line 22 def initialize(template, form, **, &block) @template = template @form = form @options = .dup.symbolize_keys @label_block = block if block end |
Class Method Details
.create(template, *args, **kwargs, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/cocooned/tags/base.rb', line 13 def create(template, *args, **kwargs, &block) return new(template, *args, **kwargs, &block) if block return new(template, *args, **kwargs) unless args.first.is_a?(String) label = args.shift new(template, *args, **kwargs) { label } end |
Instance Method Details
#render(as: :link) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/cocooned/tags/base.rb', line 29 def render(as: :link) return template.link_to('#', ) { label } if as == :link return template.(type: :button, **) { label } if as == :button raise ArgumentError, "Unsupported value for :as. Expected :link or :button, got #{as}." end |