Class: ERBLint::Linters::ArgumentMappers::Helpers::ErbBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/yattho/view_components/linters/argument_mappers/helpers/erb_block.rb

Overview

provides helpers to identify and deal with ERB blocks.

Constant Summary collapse

INTERPOLATION_REGEX =
/^<%=(?<rb>.*)%>$/.freeze

Instance Method Summary collapse

Instance Method Details

#convert(attribute) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/yattho/view_components/linters/argument_mappers/helpers/erb_block.rb', line 17

def convert(attribute)
  raise_error(attribute) unless interpolation?(attribute)

  if any?(attribute)
    convert_interpolation(attribute)
  else
    attribute.value.to_json
  end
end

#raise_if_erb_block(attribute) ⇒ Object



13
14
15
# File 'lib/yattho/view_components/linters/argument_mappers/helpers/erb_block.rb', line 13

def raise_if_erb_block(attribute)
  raise_error(attribute) if any?(attribute)
end