Sha256: b1dff81417f901b071ab42b1ff52e44c6f538092635a49de6f883e32e4225d5d

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

class Item
  attr_accessor :description, :price, :name, :revenue_center_id, :item_id, :item_images

  # :internal => :external
  def self.attribute_map
  {
      :description => :description, :price => :price, :name => :name, :revenue_center_id => :revenue_center_id, :item_id => :item_id, :item_images => :item_images

  }
  end

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

      if Item.attribute_map["description".to_sym] != nil
        name = "description".to_sym
        value = attributes["description"]
        send("#{name}=", value) if self.respond_to?(name)
	      end
      if Item.attribute_map["price".to_sym] != nil
        name = "price".to_sym
        value = attributes["price"]
        send("#{name}=", value) if self.respond_to?(name)
	      end
      if Item.attribute_map["name".to_sym] != nil
        name = "name".to_sym
        value = attributes["name"]
        send("#{name}=", value) if self.respond_to?(name)
	      end
      if Item.attribute_map["revenue_center_id".to_sym] != nil
        name = "revenue_center_id".to_sym
        value = attributes["revenue_center_id"]
        send("#{name}=", value) if self.respond_to?(name)
	      end
      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["item_images".to_sym] != nil
        name = "item_images".to_sym
        value = attributes["item_images"]
        if value.is_a?(Array)
	        array = Array.new
	        value.each do |arrayValue|
	          array.push ItemImage.new(arrayValue)
	        end
	        send("#{name}=", array) if self.respond_to?(name)
	      end
        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.3 models/item.rb