Created
January 6, 2015 15:02
-
-
Save shingara/c8cce363a1807c46702d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'decorators/application_decorator' | |
class IndexApiDecorator < ApplicationDecorator | |
def meta | |
{ | |
:count => count, | |
:name => name | |
} | |
end | |
def count | |
@component.count | |
end | |
def data | |
if decorator | |
list.map{|c| decorator.new(c) } | |
else | |
list | |
end | |
end | |
def list | |
@list ||= if @component.is_a?(ItemList) | |
@component.criteria | |
else | |
@component | |
end | |
end | |
def decorator | |
false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment