Created
October 28, 2011 18:16
-
-
Save mistersourcerer/1322955 to your computer and use it in GitHub Desktop.
stevie_restfulando
This file contains 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
class Cliente | |
include ActiveModel::Validations | |
include ActiveModel::Serialization | |
def initialize(params) | |
#pega o hash e seta os atributos normalmente. | |
end | |
# todos meus atributos e métodos normalmente aqui | |
end |
This file contains 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
class ClientesController < ApplicationController | |
def create | |
cliente = Cliente.new(params) | |
MeuServicoRemoto.new.grava_la(cliente) | |
end | |
end |
This file contains 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
class MeuServicoRemoto | |
def grava_la(um_model_qualquer) | |
faz_post(um_model_qualquer.to_json) | |
end | |
def exclui_de_la(um_model_qualquer) | |
faz_delete(um_model_qualquer.to_json) | |
end | |
private | |
def faz_post(data) | |
# post http normal aqui | |
end | |
def faz_delete(data) | |
# request http delete normal aqui | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment