module Flexirest::JsonAPIProxy::Helpers

Methods used across other modules

Public Instance Methods

singular?(word) click to toggle source
# File lib/flexirest/json_api_proxy.rb, line 11
def singular?(word)
  w = word.to_s
  w.singularize == w && w.pluralize != w
end
type(object) click to toggle source
# File lib/flexirest/json_api_proxy.rb, line 16
def type(object)
  # Retrieve the type value for JSON API from the Flexirest::Base class
  # If `alias_type` has been defined within the class, use it
  name = object.alias_type || object.class.alias_type

  # If not, guess the type value from the class name itself
  unless name
    return object.class.name.underscore.split('/').last.pluralize
  end

  name
end