Sha256: ace50320d0e0d0808b540441d90c57dcfab34db3b2774dbbf6a2e5ffca65fcc4
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
# ------------------------------------------------------ # Defined the respective AR Models # ------------------------------------------------------ module Codes class SampleClass < ActiveRecord::Base self.table_name = :codes_sample_class include CodeBox::CodeAttribute # i18n codes code_attribute :gender code_attribute :country, :lookup_type => :i18n, :code_attribute_suffix => 'iso' # lookup codes code_attribute :civil_status, :lookup_type => :lookup, :class_name => 'Codes::CivilStatus' code_attribute :ager_type, :lookup_type => :lookup, :foreign_code_attribute => 'code_id' code_attribute :country_2, :lookup_type => :associated, :class_name => 'Codes::Country' end class CivilStatus include CodeBox::ActsAsCode['single', 'married', :type => :poro] attr_accessor :code def initialize(code) @code = code end def self.all [ Codes::CivilStatus.new('single'), Codes::CivilStatus.new('married'), ] end end class AgerType @@code_cache = {} attr_accessor :code_id def initialize(code) @code_id = code self.class.cache_code(self) end def self.cache_code(code_obj) @@code_cache[code_obj.code_id] = code_obj end def self.for_code(code) @@code_cache[code] end end class Country < ActiveRecord::Base self.table_name = :codes_country end class ArCode < ActiveRecord::Base include CodeBox::ActsAsCode[:model_type => :active_record] self.table_name = :codes_ar_code end class SegmentModel include CodeBox::CodeAttribute[:i18n_model_segment => :model] attr_accessor :gender_code # i18n codes code_attribute :gender end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
code-box-0.1.0 | test/resources/models.rb |