Sha256: 322cbf6040d34a2cf5976de6fc79126258b3c2139b4af3b9281cbe39e69d22fc

Contents?: true

Size: 1.91 KB

Versions: 7

Compression:

Stored size: 1.91 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All
# Set: All cards (Initialize)
#
module Initialize;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/core/set/all/initialize.rb"; end
JUNK_INIT_ARGS = %w[missing skip_virtual id].freeze

module ClassMethods
  def new args={}, _options={}
    with_normalized_new_args args do |normalized_args|
      super normalized_args
    end
  end

  def with_normalized_new_args args={}
    args = (args || {}).stringify_keys
    delete_junk_args args
    normalize_type_args args
    normalize_content_args args
    yield args
  end

  private

  def delete_junk_args args
    JUNK_INIT_ARGS.each { |a| args.delete(a) }
  end

  def normalize_type_args args
    %w[type type_code].each { |k| args.delete(k) if args[k].blank? }
  end

  def normalize_content_args args
    args.delete("content") if args["attach"] # should not be handled here!
    args["db_content"] = args.delete "content" if args["content"]
  end
end

def initialize args={}
  args["name"] = initial_name args["name"]

  handle_set_modules args do
    handle_type args do
      super args # ActiveRecord #initialize
    end
  end
  self
end

def handle_set_modules args
  skip_modules = args.delete "skip_modules"
  yield
  include_set_modules unless skip_modules
end

def handle_type args
  type_lookup = args["type_lookup"]
  @supercard = args.delete "supercard"

  yield
  type_id_from_template if type_lookup == :force || (!type_id && type_lookup != :skip)
end

def initial_name name
  name.is_a?(String) ? name : Card::Name[name].to_s
end

def include_set_modules
  return self if @set_mods_loaded

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

def uncacheable?
  @uncacheable == true
end
end;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card/mod/core/set/all/initialize.rb ~~

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
card-1.101.5 tmpsets/set/mod002-core/all/initialize.rb
card-1.101.4 tmpsets/set/mod002-core/all/initialize.rb
card-1.101.3 tmpsets/set/mod002-core/all/initialize.rb
card-1.101.2 tmpsets/set/mod002-core/all/initialize.rb
card-1.101.1 tmpsets/set/mod002-core/all/initialize.rb
card-1.101.0 tmpsets/set/mod002-core/all/initialize.rb
card-1.100.0 tmpsets/set/mod003-core/all/initialize.rb