Class: Resourceful::Resource::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/resourceful/resource/format.rb

Direct Known Subclasses

Json, Xml

Constant Summary collapse

SUPPORTED =
['json', 'xml']

Class Method Summary collapse

Class Method Details

.build(str) ⇒ Object



30
31
32
# File 'lib/resourceful/resource/format.rb', line 30

def build(str)
  raise 'method not implemented by this format'
end

.get(format) ⇒ Object



13
14
15
16
# File 'lib/resourceful/resource/format.rb', line 13

def get(format)
  raise Resourceful::Exceptions::FormatError, "the format '#{format}' is not supported" unless SUPPORTED.include?(format.to_s)
  self.send(format)
end

.jsonObject



18
19
20
# File 'lib/resourceful/resource/format.rb', line 18

def json
  Resourceful::Resource::Json
end

.to_sObject



26
27
28
# File 'lib/resourceful/resource/format.rb', line 26

def to_s
  raise 'method not implemented by this format'
end

.xmlObject



22
23
24
# File 'lib/resourceful/resource/format.rb', line 22

def xml
  Resourceful::Resource::Xml
end