Class: Goldencobra::ArticleSerializer

Inherits:
ActiveModel::Serializer
  • Object
show all
Defined in:
app/serializers/goldencobra/article_serializer.rb

Direct Known Subclasses

ArticleCustomSerializer

Instance Method Summary collapse

Instance Method Details

#attributesObject



5
6
7
8
9
10
11
12
# File 'app/serializers/goldencobra/article_serializer.rb', line 5

def attributes
  data = super
  Goldencobra::Article.attribute_names.map(&:to_sym).each do |attr|
    data[attr] = object.send(attr)
  end
  data[:child_ids] = object.send(:child_ids)
  data      
end

#metatagsObject



18
19
20
# File 'app/serializers/goldencobra/article_serializer.rb', line 18

def metatags
  object.metatags.select([:id, :name, :value])
end

#widgetsObject



22
23
24
# File 'app/serializers/goldencobra/article_serializer.rb', line 22

def widgets
  object.widgets.pluck(:id)
end