Class: Amber::Switch::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/amber/switch/content.rb

Direct Known Subclasses

FormData, Json, Text

Defined Under Namespace

Classes: FormData, Json, Text

Constant Summary collapse

TEXT_CONTENT =
'text/plain'
FORM_DATA_CONTENT =
'application/x-www-form-urlencoded'
JSON_CONTENT =
'application/json'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, data = nil) ⇒ Content

Returns a new instance of Content.



8
9
10
11
12
13
14
# File 'lib/amber/switch/content.rb', line 8

def initialize(type, data = nil)
  @type = type

  if data
    self.data = data
  end
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



2
3
4
# File 'lib/amber/switch/content.rb', line 2

def type
  @type
end

Instance Method Details

#bodyObject



24
25
26
27
28
# File 'lib/amber/switch/content.rb', line 24

def body
  if self.class.include? Amber::Switch::ContentDelegate
    return self.serialize @data
  end
end

#body=(body) ⇒ Object



30
31
32
33
34
35
# File 'lib/amber/switch/content.rb', line 30

def body=(body)
  if self.class.include? Amber::Switch::ContentDelegate
    @data = self.deserialize body
    return
  end
end

#dataObject



16
17
18
# File 'lib/amber/switch/content.rb', line 16

def data
  @data
end

#data=(data) ⇒ Object



20
21
22
# File 'lib/amber/switch/content.rb', line 20

def data=(data)
  @data = data
end