Created
April 20, 2016 20:42
-
-
Save anonyo/849311c27a498913b5ea751b33f1e513 to your computer and use it in GitHub Desktop.
Plain Ruby class that's meant to behave like ActiveRecord model without database persistence.
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 PlainModel | |
include ActiveModel::Model | |
include ActiveSupport::Callbacks | |
include ActiveModel::Validations::Callbacks | |
define_callbacks :save | |
def save | |
if valid? | |
run_callbacks :save do | |
true | |
end | |
else | |
false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment