module ActiveNetsuite::MethodInflector::ClassMethods

Public Instance Methods

inflected_method(method) click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 17
def inflected_method(method)
  @method = method

  case
  when xmlattr_method?
    convert_xmlattr_method
  when special_method?
    convert_special_method
  else
    convert_regular_method
  end
  remove_instance_variable(:@method)
end
inflected_method_valid?(method) click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 31
def inflected_method_valid?(method)
  instance_methods(false).include?(inflected_method(method))
end

Private Instance Methods

convert_regular_method() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 37
def convert_regular_method
  @method = 'is_' + @method.to_s[0..-2] if @method.to_s.end_with?('?')
  @method = @method.to_s.camelize(:lower).to_sym
end
convert_special_method() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 46
def convert_special_method
  @method = special_methods_map[@method]
end
convert_xmlattr_method() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 42
def convert_xmlattr_method
  @method = ('xmlattr_' + @method.to_s.camelize(:lower)).to_sym
end
special_method?() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 56
def special_method?
  special_methods_map.keys.include?(@method)
end
special_methods_map() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 50
def special_methods_map
  {
    custom_fields: :customFieldList
  }
end
xmlattr_getters() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 68
def xmlattr_getters
  [:internal_id, :external_id, :script_id]
end
xmlattr_method?() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 60
def xmlattr_method?
  xmlattr_methods.include?(@method)
end
xmlattr_methods() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 64
def xmlattr_methods
  xmlattr_getters + xmlattr_setters
end
xmlattr_setters() click to toggle source
# File lib/activenetsuite/helpers/method_inflector.rb, line 72
def xmlattr_setters
  xmlattr_getters.map { |getter| (getter.to_s + '=').to_sym }
end