Class: Howkast::Processor::Categories

Inherits:
Base
  • Object
show all
Defined in:
lib/howkast/processors/categories.rb

Class Method Summary collapse

Methods inherited from Base

path

Class Method Details

.default_for(field) ⇒ Object



31
32
33
# File 'lib/howkast/processors/categories.rb', line 31

def default_for field
  [] if %w{ parents categories subcategories }.include? field
end

.filter(args, options) ⇒ Object



14
15
16
17
18
# File 'lib/howkast/processors/categories.rb', line 14

def filter args, options
  args << options.delete(:id)
  args.compact!
  options = { }
end

.parse_element(data) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/howkast/processors/categories.rb', line 20

def parse_element data
  expander = ->(key, value){ expand key, value }
  if data.has_key? 'category'
    data  = data['category']
    klass = Howkast::Model.synthesize('Category', data)
    klass.new self, data, &expander
  else
    parse_list 'category', data['categories'], &expander
  end
end