Class: Epages::Category

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/epages/category.rb

Constant Summary collapse

KEYS =
%w(category_id name page_title description special_offer images parent sub_categories sf_url links visible).collect(&:to_sym).freeze

Instance Method Summary collapse

Methods included from Utils

build_shop_from, camelize_keys, camelize_words, options_to_multipart_request, options_to_patch_request, parse_attribute_as, parse_attribute_as_array_of, parse_attributes, symbolize_keys!, to_query_options, underscorize_keys

Constructor Details

#initialize(data) ⇒ Category

Returns a new instance of Category.



12
13
14
15
16
17
18
# File 'lib/epages/category.rb', line 12

def initialize(data)
  parse_attribute_as_array_of('images', data.delete(:images), Epages::Image)
  parse_attribute_as_array_of('links', data.delete(:links), Epages::Link)
  parse_attribute_as_array_of('sub_categories', data.delete(:subCategories), Epages::Link)
  @parent = Epages::Link.new(data.delete(:parent)) if data[:parent]
  parse_attributes(data)
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
# File 'lib/epages/category.rb', line 20

def ==(other)
  return false if other.class != Epages::Category
  category_id == other.category_id && name == other.name
end