Unidom Certificate China 中国证件领域模型引擎
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The China Certificate domain model engine includes Identity Card, Driving License, and Business License 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-certificate-china'
Run the Database Migration
rake db:migrate
The migration versions start with 2001029156.
Call the Model
identity_card = Unidom::Certificate::China::IdentityCard.identification_number_is('51010519801231123X').first_or_create(
name: 'John',
address: '#1 Nanjing Street, Shanghai, China',
issuing_authority_name: 'Shanghai Police Station',
ethnicity_code: 'HA',
validity_from_date: '2015-01-01',
validity_thru_date: '2025-01-01'
)
identity_card.gender_code # '1' male, calculated from the identification_number
identity_card.birth_date # '1980-12-31', calculated from the identification_number
Unidom::Certificate::China::BusinessLicense.registration_number_is('510105012345670').first_or_create(
name: 'Google',
address: '#1 Nanjing Street, Shanghai, China',
issuing_authority_name: 'Shanghai Industry & Commerce Administration',
legal_representative_name: 'Lawrence Edward Page',
validity_from_date: '2015-01-01',
validity_thru_date: '2025-01-01'
)
Include the Concerns
include Unidom::Certificate::China::Concerns::AsBusinessLicenseCertificated
include Unidom::Certificate::China::Concerns::AsIdentityCardCertificated
As Business License Certificated
The As Business License Certificated do the following tasks for the includer automatically:
- Include the As Certificated concern
- Define the has_many :china_business_licenses macro as:
has_many :china_business_licenses, through: :certificatings, source: :certification, source_type: 'Unidom::Certificate::China::BusinessLicense'
As Identity Card Certificated
The As Identity Card Certificated do the following tasks for the includer automatically:
- Include the As Certificated concern
- Define the has_many :china_identity_cards macro as:
has_many :china_identity_cards, through: :certificatings, source: :certification, source_type: 'Unidom::Certificate::China::IdentityCard'
Validator
validates :identification_number, presence: true, identification_number: true