Sha256: 24bf34e87d71b21b117d7c9f6de852bb9954a86bebbfa0901866b3b454df3f95

Contents?: true

Size: 1019 Bytes

Versions: 7

Compression:

Stored size: 1019 Bytes

Contents

JUNK_INIT_ARGS = %w( missing skip_virtual id ).freeze

module ClassMethods
  def new args={}, _options={}
    args = (args || {}).stringify_keys
    JUNK_INIT_ARGS.each { |a| args.delete(a) }
    %w( type type_code ).each { |k| args.delete(k) if args[k].blank? }
    args.delete('content') if args['attach'] # should not be handled here!
    super args
  end
end

def initialize args={}
  args['name'] = args['name'].to_s
  args['db_content'] = args.delete('content') if args['content']
  @supercard = args.delete 'supercard' # must come before name =
  skip_modules = args.delete 'skip_modules'
  skip_type_lookup = args['skip_type_lookup']

  super args # ActiveRecord #initialize
  self.type_id = get_type_id_from_structure if !type_id && !skip_type_lookup
  include_set_modules unless skip_modules
  self
end

def include_set_modules
  unless @set_mods_loaded
    set_modules.each do |m|
      singleton_class.send :include, m
    end
    assign_set_specific_attributes
    @set_mods_loaded = true
  end
  self
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
card-1.18.6 mod/01_core/set/all/initialize.rb
card-1.18.5 mod/01_core/set/all/initialize.rb
card-1.18.4 mod/01_core/set/all/initialize.rb
card-1.18.3 mod/01_core/set/all/initialize.rb
card-1.18.2 mod/01_core/set/all/initialize.rb
card-1.18.1 mod/01_core/set/all/initialize.rb
card-1.18.0 mod/01_core/set/all/initialize.rb