Module: Restful

Defined in:
lib/restful/apimodel/map.rb,
lib/restful.rb,
lib/restful/rails.rb,
lib/restful/apimodel/link.rb,
lib/restful/serializers/base.rb,
lib/restful/apimodel/resource.rb,
lib/restful/apimodel/attribute.rb,
lib/restful/apimodel/collection.rb,
lib/restful/rails/action_controller.rb,
lib/restful/converters/active_record.rb,
lib/restful/serializers/hash_serializer.rb,
lib/restful/serializers/json_serializer.rb,
lib/restful/serializers/params_serializer.rb,
lib/restful/serializers/atom_like_serializer.rb,
lib/restful/rails/active_record/configuration.rb,
lib/restful/rails/active_record/metadata_tools.rb

Overview

Handle ActiveRecord associations and such like.

Defined Under Namespace

Modules: ApiModel, Converters, Rails, Serializers

Constant Summary collapse

MAJOR =
0
MINOR =
1
REVISION =
2
VERSION =
[MAJOR, MINOR, REVISION].join(".")

Class Method Summary collapse

Class Method Details

.attr(*options) ⇒ Object



49
50
51
# File 'lib/restful.rb', line 49

def self.attr(*options)
  Restful::ApiModel::Attribute.new(*options)    
end

.cfg(*options) ⇒ Object

Shortcuts past the namespaces



45
46
47
# File 'lib/restful.rb', line 45

def self.cfg(*options)
  Restful::Rails::ActiveRecord::Configuration::Config.new(*options)
end

.collection(*options) ⇒ Object



57
58
59
# File 'lib/restful.rb', line 57

def self.collection(*options)
  Restful::ApiModel::Collection.new(*options)
end


53
54
55
# File 'lib/restful.rb', line 53

def self.link(*options)
  Restful::ApiModel::Link.new(*options)
end

.method_missing(method, *args, &block) ⇒ Object

Restful.from_xml, #from_atom_like. Methods correspond with

resgistered serializers.


28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/restful.rb', line 28

def self.method_missing(method, *args, &block)
  if method.to_s.match(/^from_(.*)$/)
    if serializer_clazz = Restful::Serializers::Base.serializers[type = $1.to_sym]
      s = serializer_clazz.new
      s.deserialize(args.first)
    else
      super
    end
  else
    super
  end
end

.resource(*options) ⇒ Object



61
62
63
# File 'lib/restful.rb', line 61

def self.resource(*options)
  Restful::ApiModel::Resource.new(*options)
end