Class: Served::Resource::Base

Inherits:
Object
  • Object
show all
Includes:
Attributable, Configurable, Requestable, Serializable, Validatable
Defined in:
lib/served/resource/base.rb,
lib/served/error.rb

Overview

Service Resources should inherit directly from this class. Provides interfaces necessary for communicating with services based on the namespace. Classes should be namespaced under Services::ServiceName where ServiceName is the name of the service the resource lives on. The resource determines the host of the service based on this this namespace and what is in the configuration.

Service Resources supports some ActiveModel validations so that a developer can include client side validations if desired. Validation options can be passed to the #attribute class method using the same options as ActiveModel#validate.

A resource may also serialize values as specific classes, including nested resources. If serialize is set to a Served Resource, it will validate the nested resource as well as the top level.

Defined Under Namespace

Classes: ServiceError

Constant Summary

Constants included from Validatable

Validatable::SUPPORTED_VALIDATIONS

Constants included from Requestable

Requestable::HEADERS

Method Summary

Methods included from Serializable

#dump, #load, #to_json

Methods included from Validatable

#save!

Methods included from Attributable

#attributes, #initialize

Methods included from Requestable

#destroy, #reload, #save