module Greeve::Helpers::AddAttribute
Adds a helper method to add an attribute to the attributes hash instance variable.
Private Instance Methods
add_attribute(name, opts = {})
click to toggle source
Add an attribute to the attributes hash instance variable.
@param name [String] name of the attribute method @param opts [Hash] option hash passed from the attribute DSL helper method
# File lib/greeve/helpers/add_attribute.rb, line 12 def add_attribute(name, opts = {}) name = name.to_sym raise "Attribute `#{name}` defined more than once" if @attributes[name] raise "`:xpath` not specified for `#{name}`" unless opts[:xpath] @attributes[name] = { xpath: opts[:xpath], type: opts[:type], } end