Created
December 14, 2013 03:02
-
-
Save therealjasonkenney/7955229 to your computer and use it in GitHub Desktop.
Taking a domain out of rails example.
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
# The Database model, it does | |
# validation that is required for db integrity. | |
class User < ActiveRecord::Base | |
validates :presence => :email | |
end | |
# Just your average active model, this one handles a login. | |
# This assumes a railtie that provides a Validator class which takes domain | |
# as an argument and passes the Login class with its associations to | |
# the domain class. | |
class Login < ActiveModel::Base | |
belongs_to :user | |
has_one :session | |
has_many :hours | |
validates :domain => :authentication | |
delegate :session_hash, :to => :session | |
end | |
# In the domain gem | |
class Authentication < Entity::Base | |
validate :password_matches | |
validate :account_active | |
# Actual functions that take the login object and | |
# peruse its information. The Login object is responsible | |
# for telling this object how to get its data. | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment