Module: Mince::Model
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mince/model.rb,
lib/mince/model/fields.rb,
lib/mince/model/finders.rb,
lib/mince/model/data_model.rb,
lib/mince/model/persistence.rb
Overview
Model
The mince model is a module that provides standard model to data behavior to the Mince data model mixing for a specific model.
Simply mixin this module in order to get a wrapper class to interact with a mince interface for a specific collection
Example:
require 'mince'
class BookDataModel
include Mince::DataModel
data_collection :books
data_fields :title, :publisher
end
class Book
include Mince::Model
data_model BookDataModel
fields :title, :publisher
end
book = Book.new title: 'The World In Photographs', publisher: 'National Geographic'
book.save
By including this module, you are including DataModel, Fields, Persistence, and Finders.
However, you can choose which modules you would like by including those modules individually so that you can have flexibility an lighter weight help to implement your models.
class AvailableBook
include Mince::Model::DataModel
data_collection :books
def self.all
data_collection.all_by_fields(library: "St. Louis - Downtown", available: true).map{ |a| new(a) }
end
end
Defined Under Namespace
Modules: DataModel, Fields, Finders, Persistence