class SimpleRewriter::AttributeResolver
Constants
- INDEX_OF_ATTRIBUTE_NAME
Attributes
attribute[R]
Public Class Methods
new(attribute:)
click to toggle source
# File lib/simple_rewriter/attribute_resolver.rb, line 3 def initialize(attribute:) @attribute = attribute end
Public Instance Methods
call()
click to toggle source
# File lib/simple_rewriter/attribute_resolver.rb, line 7 def call finalize end
Private Instance Methods
convert_array_options(array)
click to toggle source
# File lib/simple_rewriter/attribute_resolver.rb, line 31 def convert_array_options(array) array.each_with_object({}) { |option, obj| converted_option(option, obj) } end
converted_option(option, obj)
click to toggle source
# File lib/simple_rewriter/attribute_resolver.rb, line 35 def converted_option(option, obj) return obj[option.keys[0]] = option.values[0] if option.is_a?(Hash) obj[option] = true end
extract_options()
click to toggle source
# File lib/simple_rewriter/attribute_resolver.rb, line 22 def extract_options options = attribute.values return options[0] if options[0].is_a?(Hash) return convert_array_options(options.flatten) if options.is_a?(Array) options.flatten end
extracted_attribute()
click to toggle source
# File lib/simple_rewriter/attribute_resolver.rb, line 41 def extracted_attribute return attribute.keys[INDEX_OF_ATTRIBUTE_NAME] if attribute.is_a?(Hash) attribute end
finalize()
click to toggle source
# File lib/simple_rewriter/attribute_resolver.rb, line 47 def finalize OpenStruct.new(attribute: extracted_attribute, options: options) end
options()
click to toggle source
# File lib/simple_rewriter/attribute_resolver.rb, line 18 def options return extract_options if attribute.is_a?(Hash) end