Sha256: 8f3606eea2a8dbd8ed40d08d5236643823bca4d3731f2ec2c8a849475c41afea

Contents?: true

Size: 1.29 KB

Versions: 8

Compression:

Stored size: 1.29 KB

Contents

def patterns
  @patterns ||= set_patterns.map { |sub| sub.new(self) }.compact
end

def patterns_with_new
  new_card? ? patterns_without_new[1..-1] : patterns_without_new
end
alias_method_chain :patterns, :new

def reset_patterns
  @set_mods_loaded = @patterns = @set_modules = @junction_only = @set_names = @template = @rule_set_keys = @virtual = nil
  true
end

def reset_patterns_if_rule saving=false
  if !new_card? && is_rule?
    set = left
    set.reset_patterns
    set.include_set_modules

    #this is really messy.
    if saving
      self.add_to_read_rule_update_queue( set.item_cards limit: 0 ) if right.id == Card::ReadID
    end
  end
end

def safe_set_keys
  patterns.map( &:safe_key ).reverse * " "
end

def set_modules
  @set_modules ||= patterns_without_new[0..-2].reverse.map(&:module_list).flatten.compact
end

def set_format_modules klass
  @set_format_modules ||= {}
  @set_format_modules[klass] = patterns_without_new[0..-2].reverse.map do |pattern|
    pattern.format_module_list klass
  end.flatten.compact
end

def set_names
  if @set_names.nil?
    @set_names = patterns.map &:to_s
    Card.set_members @set_names, key
  end
  @set_names
end

def rule_set_keys
  set_names #this triggers set_members cache.  need better solution!
  @rule_set_keys ||= patterns.map( &:rule_set_key ).compact
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
card-1.16.14 mod/01_core/set/all/pattern.rb
card-1.16.13 mod/01_core/set/all/pattern.rb
card-1.16.12 mod/01_core/set/all/pattern.rb
card-1.16.11 mod/01_core/set/all/pattern.rb
card-1.16.10 mod/01_core/set/all/pattern.rb
card-1.16.9 mod/01_core/set/all/pattern.rb
card-1.16.8 mod/01_core/set/all/pattern.rb
card-1.16.7 mod/01_core/set/all/pattern.rb