Skip to content

Instantly share code, notes, and snippets.

@anonyo
Created April 20, 2016 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonyo/849311c27a498913b5ea751b33f1e513 to your computer and use it in GitHub Desktop.
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.
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