Unidom Stapar 统计模式识别模型引擎

Documentation License

Gem Version Dependency Status

Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Stapar domain model engine includes Sample and Matching models. Unidom (统一领域对象模型)是一系列的领域模型引擎。统计模式识别领域模型引擎包括采样和匹配的模型。

Recent Update

Check out the Road Map to find out what's the next. Check out the Change Log to find out what's new.

Usage in Gemfile

gem 'unidom-stapar'

Run the Database Migration

rake db:migrate

The migration versions start with 200601.

Call the Model

PatternMatching

Include the Concerns

include Unidom::Stapar::Concerns::AsSample
include Unidom::Stapar::Concerns::AsFeature

As Feature

The As Feature concern do the following tasks for the includer automatically:

  1. Define the has_many :stapar_carts macro as: has_many :stapar_carts, class_name: 'Unidom::stapar::staparCart', as: :shopper
  2. Define the #get_cart! method as: get_cart!(from: nil, at: Time.now)
  3. Define the #get_cart? method as: get_cart?(from: nil, at: Time.now)

Disable the Model & Migration

If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.

# config/initializers/unidom.rb
Unidom::Common.configure do |options|

  options[:neglected_namespaces] = %w{
    Unidom::Stapar
  }

end

RSpec examples

RSpec example manifest (run automatically)

# spec/models/unidom_spec.rb
require 'unidom/stapar/models_rspec'

# spec/types/unidom_spec.rb
require 'unidom/stapar/types_rspec'

# spec/validators/unidom_spec.rb
require 'unidom/stapar/validators_rspec'

RSpec shared examples (to be integrated)

# lib/unidom.rb
def initialize_unidom

  Snapshot.class_eval do
    include Unidom::Stapar::Concerns::AsSample
    include Unidom::Stapar::Concerns::AsFeature
  end

end

# spec/rails_helper.rb
require 'unidom'
initialize_unidom

# spec/support/unidom_rspec_shared_examples.rb
require 'unidom/stapar/rspec_shared_examples'

# spec/models/unidom/party/person_spec.rb
describe Snapshot, type: :model do

  context do

    model_attribtues = {
      name: 'Tim'
    }

    it_behaves_like 'Unidom::Stapar::Concerns::AsSample', model_attribtues
    it_behaves_like 'Unidom::Stapar::Concerns::AsFeature', model_attribtues

  end

end