Module: ShopifyClient::Resource::Base::ClassMethods

Defined in:
lib/shopify-client/resource/base.rb

Instance Method Summary collapse

Instance Method Details

#resource(name_plural, name_singular = nil) ⇒ Object

Set the remote API resource name for the subclass. If a singular is not provided, the plural will be used, without any trailing ā€˜sā€™.

Examples:

resource :orders
resource :orders, :order

Parameters:

  • resource_plural (String, #to_s)
  • resource_singular (String, #to_s, nil)


18
19
20
21
22
23
# File 'lib/shopify-client/resource/base.rb', line 18

def resource(name_plural, name_singular = nil)
  define_method(:resource_name) { name_plural.to_s }
  define_method(:resource_name_singular) do
    name_singular ? name_singular.to_s :  name_plural.to_s.sub(/s$/, '')
  end
end