Sha256: 14685543e4559c9b66165421a5966447fdf49f2d6a138f2ce7512d3398a5212d

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

class Item
  attr_accessor :item_id, :instructions, :modifiers, :quantity

  # :internal => :external
  def self.attribute_map
  {
      :item_id => :item_id, :instructions => :instructions, :modifiers => :modifiers, :quantity => :quantity

  }
  end

  def initialize(attributes = {})
    # Morph attribute keys into undescored rubyish style
    if attributes.to_s != ""

      if Item.attribute_map["item_id".to_sym] != nil
        name = "item_id".to_sym
        value = attributes["item_id"]
        send("#{name}=", value) if self.respond_to?(name)
	      end
      if Item.attribute_map["instructions".to_sym] != nil
        name = "instructions".to_sym
        value = attributes["instructions"]
        send("#{name}=", value) if self.respond_to?(name)
	      end
      if Item.attribute_map["modifiers".to_sym] != nil
        name = "modifiers".to_sym
        value = attributes["modifiers"]
        if value.is_a?(Array)
	        array = Array.new
	        value.each do |arrayValue|
	          array.push Modifier.new(arrayValue)
	        end
	        send("#{name}=", array) if self.respond_to?(name)
	      end
        end
      if Item.attribute_map["quantity".to_sym] != nil
        name = "quantity".to_sym
        value = attributes["quantity"]
        send("#{name}=", value) if self.respond_to?(name)
	      end
      end
  end

  def to_body
    body = {}
    Item.attribute_map.each_pair do |key,value|
      body[value] = self.send(key) unless self.send(key).nil?
    end
    body
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
subtledata-0.0.5 models/item.rb