Class: SirenClient::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/siren_client/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Field

Returns a new instance of Field.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/siren_client/field.rb', line 5

def initialize(data)
  if data.class != Hash
    raise ArgumentError, "You must pass in a Hash to SirenClient::Action.new"
  end
  @payload = data

  @name  = @payload['name']  || ''
  @type  = @payload['type']  || 'text'
  @value = @payload['value'] || ''
  @title = @payload['title'] || ''
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/siren_client/field.rb', line 3

def name
  @name
end

#payloadObject (readonly)

Returns the value of attribute payload.



3
4
5
# File 'lib/siren_client/field.rb', line 3

def payload
  @payload
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/siren_client/field.rb', line 3

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/siren_client/field.rb', line 3

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/siren_client/field.rb', line 3

def value
  @value
end