Class: Nodepile::PileOrganizer::RuleCache

Inherits:
Object
  • Object
show all
Defined in:
lib/nodepile/pile_organizer.rb,
lib/nodepile/pile_organizer.rb

Overview

Represents cached information about a single specific rule

Instance Method Summary collapse

Constructor Details

#initialize(rule_erec) ⇒ RuleCache

Returns a new instance of RuleCache.

Parameters:



225
226
227
228
229
230
# File 'lib/nodepile/pile_organizer.rb', line 225

def initialize(rule_erec)
    @er = rule_erec.freeze  #just for to avoid casual alteration
    raise "Only ERecs of type :rule may be stored in this structure" unless self.type == :rule
    @verifiers = [*self.key].map{|s| Nodepile::InputColumnSpecs.make_pattern_match_verifier(s)}
    @rule_eval = RuleRecordEvaluator.new(@er)
end

Instance Method Details

#eval_using(kaa) ⇒ Object



248
# File 'lib/nodepile/pile_organizer.rb', line 248

def eval_using(kaa) = @rule_eval.calculate_rule(kaa)

#inspectObject



232
233
234
# File 'lib/nodepile/pile_organizer.rb', line 232

def inspect 
    "#<#{self.class}:0x#{object_id} key=#{self.key.inspect} > "
end

#is_impliedObject



237
# File 'lib/nodepile/pile_organizer.rb', line 237

def is_implied = @er['@is_implied']

#keyObject



238
# File 'lib/nodepile/pile_organizer.rb', line 238

def key = @er['@key']

#match?(kaa) ⇒ Boolean

Parameters:

  • kaa (KeyedArrayAccessor)

    a set of field values that will tested against this rule for matching.

Returns:

  • (Boolean)


247
# File 'lib/nodepile/pile_organizer.rb', line 247

def match?(kaa) = @rule_eval.match_record?(kaa)

#relevant_entity_typeObject



251
# File 'lib/nodepile/pile_organizer.rb', line 251

def relevant_entity_type = @er['@key'].is_a?(String) ? :node : :edge

#typeObject



236
# File 'lib/nodepile/pile_organizer.rb', line 236

def type = @er['@type']

#uses_dynamic_match?Boolean

Note that a rule that uses dynamic matching cannot precalculate which records it matches and must (to be safe) reclculate the match in response to any changes

Returns:

  • (Boolean)


243
# File 'lib/nodepile/pile_organizer.rb', line 243

def uses_dynamic_match? = @rule_eval.uses_dynamic_match?