Class: Dynamicloud::API::RecordImpl

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

Overview

This class represents a record in Dynamicloud

Author:

  • Eleazar Gomez

Since:

  • 8/24/15

Version:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

#initializeRecordImpl

Returns a new instance of RecordImpl.

Since:

  • 8/24/15



243
244
245
# File 'lib/dynamic_api.rb', line 243

def initialize
  @map = {}
end

Instance Method Details

#add_value(attribute, value) ⇒ Object

Adds a new value paired with attribute

Parameters:

  • attribute

    attribute to be paired

  • value

    value

Since:

  • 8/24/15



278
279
280
# File 'lib/dynamic_api.rb', line 278

def add_value(attribute, value)
  @map[attribute] = value
end

#get_value(attribute) ⇒ Object

gets the value paired with attribute

Parameters:

  • attribute

    attribute to use

Returns:

  • the value paired with attribute

Raises:

  • (IllegalStateException)

Since:

  • 8/24/15



250
251
252
253
254
255
256
257
258
259
# File 'lib/dynamic_api.rb', line 250

def get_value(attribute)
  obj = @map[attribute]
  if obj
    if obj.is_a?(String)
      return obj.to_s
    end
  end

  raise IllegalStateException, "The attribute #{attribute} doesn't have a paired string."
end

#get_values(attribute) ⇒ Object

get the values paired with attribute

Parameters:

  • attribute

    attribute to use

Returns:

  • the values paired with attribute

Raises:

  • (IllegalStateException)

Since:

  • 8/24/15



264
265
266
267
268
269
270
271
272
273
# File 'lib/dynamic_api.rb', line 264

def get_values(attribute)
  obj = @map[attribute]
  if obj
    if obj.respond_to?(:each)
      return obj
    end
  end

  raise IllegalStateException, "Tha attribute #{attribute} doesn't have a paired string array."
end