No commit activity in last 3 years
No release in over 3 years
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The China Region domain model engine includes Region and its relative models. Unidom (统一领域对象模型)是一系列的领域模型引擎。中国联系方式领域模型引擎包括中国大陆的移动电话号码及其相关的模型。
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Unidom Contact China 中国联系方式领域模型引擎

Documentation License

Gem Version Dependency Status

Unidom (UNIfied Domain Object Model) is a series of domain model engines. The China Contact domain model engine includes China Mobile Phone Number and its relative 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-contact-china'

Run the Database Migration

rake db:migrate

The migration versions start with 2001039156.

Call the Model

phone_number = Unidom::Contact::China::MobilePhoneNumber.new phone_number: '13912345678'
phone_number.save!

Unidom::Contact::China::MobilePhoneNumber.valid_at.alive.first
# Find the first active China mobile phone number

Unidom::Contact::China::MobilePhoneNumber.phone_number_is('13912345678').first
# Find the mobile phone number per the given phone number.

Include the Concerns

include Unidom::Contact::China::Concerns::AsMobilePhoneNumberSubscriber

As Mobile Phone Number Subscriber concern

The As Mobile Phone Number Subscriber concern do the following tasks for the includer automatically:

  1. Define the has_many :china_mobile_phone_numbers macro as: has_many :china_mobile_phone_numbers, through: :contact_subscriptions, source: :contact, source_type: 'Unidom::Contact::China::MobilePhoneNumber'

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::Contact::China
  }

end

RSpec examples

RSpec example manifest (run automatically)

# spec/models/unidom_spec.rb
require 'unidom/contact/china/models_rspec'

# spec/types/unidom_spec.rb
require 'unidom/contact/china/types_rspec'

# spec/validators/unidom_spec.rb
require 'unidom/contact/china/validators_rspec'

RSpec shared examples (to be integrated)

# lib/unidom.rb
def initialize_unidom

  Unidom::Party::Person.class_eval do
    include Unidom::Contact::China::Concerns::AsMobilePhoneNumberSubscriber
  end

end

# spec/rails_helper.rb
require 'unidom'
initialize_unidom

# spec/support/unidom_rspec_shared_examples.rb
require 'unidom/contact/china/rspec_shared_examples'

# spec/models/unidom/party/person_spec.rb
describe Unidom::Party::Person, type: :model do

  model_attribtues = {
    name: 'Tim'
  }

  it_behaves_like 'Unidom::Contact::China::Concerns::AsMobilePhoneNumberSubscriber', model_attribtues

end