Class: XapianDb::DocumentBlueprint::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/xapian_db/document_blueprint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass_name, trigger_attributes, block) ⇒ Dependency

Constructor

Parameters:

  • klass_name (String)

    Name of the dependent class

  • trigger_attributes (Array)

    List of attributes to watch for changes (if empty, triggers on any change)

  • [Block] (Hash)

    a customizable set of options



464
465
466
# File 'lib/xapian_db/document_blueprint.rb', line 464

def initialize(klass_name, trigger_attributes, block)
  @dependent_on, @trigger_attributes, @block = klass_name, trigger_attributes.map(&:to_s), block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block



458
459
460
# File 'lib/xapian_db/document_blueprint.rb', line 458

def block
  @block
end

#dependent_onObject (readonly)

Returns the value of attribute dependent_on



458
459
460
# File 'lib/xapian_db/document_blueprint.rb', line 458

def dependent_on
  @dependent_on
end

#trigger_attributesObject (readonly)

Returns the value of attribute trigger_attributes



458
459
460
# File 'lib/xapian_db/document_blueprint.rb', line 458

def trigger_attributes
  @trigger_attributes
end

Instance Method Details

#interested_in?(changed_attrs) ⇒ Boolean

Returns:

  • (Boolean)


468
469
470
471
# File 'lib/xapian_db/document_blueprint.rb', line 468

def interested_in?(changed_attrs)
  return true if @trigger_attributes.empty?
  (@trigger_attributes & changed_attrs).any?
end