Module: Flexirest::JsonAPIProxy::Helpers

Included in:
Request::Params, Request::Params::Parameters, Response
Defined in:
lib/flexirest/json_api_proxy.rb

Overview

Methods used across other modules

Instance Method Summary collapse

Instance Method Details

#singular?(word) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# 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) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# 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