Class: Lattice::Resource

Inherits:
Webmachine::Resource
  • Object
show all
Includes:
Celluloid::Logger
Defined in:
lib/lattice/resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accept_content_type(content_types) ⇒ Object Also known as: accept



23
24
25
26
27
28
# File 'lib/lattice/resource.rb', line 23

def accept_content_type(content_types)
  content_types.each do |key, value|
    self.content_types_accepted ||= []
    content_types_accepted << [key, value]
  end
end

.allow_method(*methods) ⇒ Object Also known as: allow



17
18
19
20
# File 'lib/lattice/resource.rb', line 17

def allow_method(*methods)
  self.allowed_methods ||= []
  self.allowed_methods += methods.map(&:to_s).map(&:upcase)
end

.provide_content_type(content_types) ⇒ Object



31
32
33
34
35
36
# File 'lib/lattice/resource.rb', line 31

def provide_content_type(content_types)
  content_types.each do |key, value|
    self.content_types_provided ||= []
    content_types_provided << [key, value]
  end
end

.provide_encoding(encodings) ⇒ Object



38
39
40
41
# File 'lib/lattice/resource.rb', line 38

def provide_encoding(encodings)
  self.encodings_provided ||= {}
  encodings_provided.merge!(encodings)
end

Instance Method Details

#allowed_methodsObject



44
45
46
47
48
# File 'lib/lattice/resource.rb', line 44

def allowed_methods
  methods = self.class.allowed_methods
  return methods if methods && !methods.empty?
  super
end

#content_types_acceptedObject



50
51
52
53
54
# File 'lib/lattice/resource.rb', line 50

def content_types_accepted
  types = self.class.content_types_accepted
  return types if types && !types.empty?
  super
end

#content_types_providedObject



56
57
58
59
60
# File 'lib/lattice/resource.rb', line 56

def content_types_provided
  types = self.class.content_types_provided
  return types if types && !types.empty?
  super
end

#encodings_providedObject



62
63
64
65
66
# File 'lib/lattice/resource.rb', line 62

def encodings_provided
  encodings = self.class.encodings_provided
  return encodings if encodings && !encodings.empty?
  super
end

#handle_exception(ex) ⇒ Object



68
69
70
# File 'lib/lattice/resource.rb', line 68

def handle_exception(ex)
  crash "#{self.class} crashed!", ex
end