# encoding: utf-8 # # Copyright (C) 2011-2012 AdMaster, Inc. module <%= module_name %> class <%= camelize name %> include Apimaster::Mapper include Mongoid::Document field :title, type: String field :content, type: String attr_options :title, accessor: [:get, :list], required: [:post], optional: [:patch] attr_options :content, accessor: [:get], required: [:post], optional: [:patch] validates :title, length: { minimum: 2, maximum: 30 } # Embedded 1-1 # embeds_one :label, class_name: "<%= module_name %>::Label" class << self def get id find id or raise MissingError.new(<%= name %>, :id) end end end end