app/controllers/epp/base_controller.rb
# Adds error to epp_errors if element is missing or blank
# Returns last element of selectors if it exists
#
# requires 'transfer'
#
# TODO: Add possibility to pass validations / options in the method
Adds error to epp_errors if element is missing or blank
Returns last element of selectors if it exists

requires 'transfer'

Add possibility to pass validations / options in the method
Adds error to epp_errors if element is missing or blank Returns last element of selectors if it exists requires ' transfer ' Add possibility to pass validations / options in the method
def requires(*selectors)
      options = selectors.extract_options!
      allow_blank = options[:allow_blank] ||= false 
      el, missing = nil, nil
      selectors.each do |selector|
        full_selector = [@prefix, selector].compact.join(' ')
        attr = selector.split('>').last.strip.underscore
        el = params[:parsed_frame].css(full_selector).first
        if allow_blank
          missing = el.nil?
        else
          missing = el.present? ? el.text.blank? : true
        end
        next unless missing
        epp_errors.add(:epp_errors,
                       code: '2003',
                       message: I18n.t('errors.messages.required_parameter_missing',
                                       key: "#{full_selector} [#{attr}]"))
      end
      missing ? false : el 
    end
def requires ( * selectors ) options = selectors . extract_options! allow_blank = options [ :allow_blank ] ||= false el , missing = nil , nil selectors . each do | selector | full_selector = [ @prefix , selector ] . compact . join ( ' ' ) attr = selector . split ( '>' ) . last . strip . underscore el = params [ :parsed_frame ] . css ( full_selector ) . first if allow_blank missing = el . nil? else missing = el . present? ? el . text . blank? : true end next unless missing epp_errors . add ( :epp_errors , code : '2003' , message : I18n . t ( 'errors.messages.required_parameter_missing' , key : "#{full_selector} [#{attr}]" ) ) end missing ? false : el end
Adds error to epp_errors if element is missing or blank
Returns last element of selectors if it exists
Adds error to epp_errors if element is missing or blank Returns last element of selectors if it exists
# allow_blank is false by default # return last selector if it was present
selectors
<not_specific>