Skip to content

Commit

Permalink
Missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Oct 31, 2014
1 parent 782ca24 commit ef48e6c
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache
coverage
*.orig
16 changes: 16 additions & 0 deletions app/serializers/devise_token_auth/error_messages_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module DeviseTokenAuth
class ErrorMessagesSerializer
def initialize(*args)
@args = args
end

attr_reader :args

def as_json(options)
{
status: 'error',
errors: args
}
end
end
end
24 changes: 24 additions & 0 deletions app/serializers/devise_token_auth/resource_errors_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module DeviseTokenAuth
class ResourceErrorsSerializer
def initialize(*args)
@args = args
end

attr_reader :args

def as_json(options)
resource = args[0]
response = {
status: "error",
data: resource.as_json(except: [:tokens, :created_at, :updated_at])
}
if args.length > 1
args.shift
response[:errors] = args
else
response[:errors] = resource.errors.to_hash.merge(full_messages: resource.errors.full_messages)
end
response
end
end
end
17 changes: 17 additions & 0 deletions app/serializers/devise_token_auth/resource_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module DeviseTokenAuth

class ResourceSerializer
def initialize(resource)
@resource = resource
end
attr_reader :resource

def as_json(options)
{
status: "success",
data: resource.as_json(except: [:tokens, :created_at, :updated_at])
}
end

end
end
15 changes: 15 additions & 0 deletions app/serializers/devise_token_auth/success_message_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module DeviseTokenAuth
class SuccessMessageSerializer
def initialize(message)
@message = message
end

attr_reader :message

def as_json(options)
json_response = { status: 'success' }
json_response[:message] = message if message
json_response
end
end
end

0 comments on commit ef48e6c

Please sign in to comment.