Module: RoadForest::Resource::Role::Writable

Included in:
RoadForest::Resource::RDF::LeafItem, RoadForest::Resource::RDF::ParentItem
Defined in:
lib/roadforest/resource/role/writable.rb

Defined Under Namespace

Classes: IncludeOrder

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allowed_methodsObject



9
10
11
# File 'lib/roadforest/resource/role/writable.rb', line 9

def self.allowed_methods
  %w[POST PUT DELETE]
end

.included(mod) ⇒ Object



13
14
15
16
17
18
# File 'lib/roadforest/resource/role/writable.rb', line 13

def self.included(mod)
  if mod.ancestors.include?(HasChildren)
    #Might regret this later - some kind of "I promise to fix it?"
    raise IncludeOrder, "Writable has to be included before HasChildren"
  end
end

Instance Method Details

#content_types_acceptedObject



24
25
26
# File 'lib/roadforest/resource/role/writable.rb', line 24

def content_types_accepted
  content_engine.parsers.type_map
end

#delete_resourceObject



37
38
39
# File 'lib/roadforest/resource/role/writable.rb', line 37

def delete_resource
  @interface.delete(params)
end

#known_content_type(content_type) ⇒ Object



32
33
34
35
# File 'lib/roadforest/resource/role/writable.rb', line 32

def known_content_type(content_type)
  content_type = Webmachine::MediaType.parse(content_type)
  content_types_accepted.any?{|ct, _| content_type.match?(ct)}
end

#post_is_createObject



20
21
22
# File 'lib/roadforest/resource/role/writable.rb', line 20

def post_is_create
  true
end

#request_bodyObject



28
29
30
# File 'lib/roadforest/resource/role/writable.rb', line 28

def request_body
  @request.body
end