Skip to content

Instantly share code, notes, and snippets.

@burtlo
Created March 6, 2011 08:48
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 burtlo/857148 to your computer and use it in GitHub Desktop.
Save burtlo/857148 to your computer and use it in GitHub Desktop.
Utilizing modules to reduce element declarations
require 'happymapper'
module Publication
def self.included(receiver)
receiver.element :featured, Boolean, :tag => 'isFeatured'
receiver.element :exclusive, Boolean, :tag => 'isExclusive'
receiver.element :sponsored, Boolean, :tag => 'isSponsored'
end
end
class Article
include HappyMapper
has_one :title, String
include Publication
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment