Class: PowerReviews::FeedItem
- Inherits:
-
Object
- Object
- PowerReviews::FeedItem
- Defined in:
- lib/power_reviews/feed_item.rb
Constant Summary collapse
- CATEGORY_SEPARATOR =
" > "
- REQUIRED_FIELDS =
[:product_url, :name, :description, :price, :image_url, :category, :page_id]
- OPTIONAL_FIELDS =
[:manufacturer_id, :shipping, :brand, :upc, :specifications, :in_stock, :affiliate_id, :affiliate_url, :add_to_cart_url, :page_id_variant]
- FIELDS =
REQUIRED_FIELDS + OPTIONAL_FIELDS
Class Method Summary collapse
Instance Method Summary collapse
- #category=(cat) ⇒ Object
-
#initialize(attributes = {}) ⇒ FeedItem
constructor
A new instance of FeedItem.
- #values ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ FeedItem
Returns a new instance of FeedItem.
15 16 17 18 19 20 |
# File 'lib/power_reviews/feed_item.rb', line 15 def initialize(attributes = {}) attributes ||= {} attributes.each do |field, value| self.send("#{field.to_s}=".intern, value) end end |
Class Method Details
.field_names ⇒ Object
30 31 32 |
# File 'lib/power_reviews/feed_item.rb', line 30 def self.field_names FIELDS.collect { |f| f.to_s } end |
Instance Method Details
#category=(cat) ⇒ Object
22 23 24 |
# File 'lib/power_reviews/feed_item.rb', line 22 def category=cat @category = cat.is_a?(Array) ? cat.join(CATEGORY_SEPARATOR) : cat.to_s end |
#values ⇒ Object
26 27 28 |
# File 'lib/power_reviews/feed_item.rb', line 26 def values FIELDS.collect {|f| self.send(f) } end |