class Attentive::CompositeEntity
Attributes
entities[RW]
entities[R]
Public Class Methods
define(entity_name, *entities)
click to toggle source
# File lib/attentive/composite_entity.rb, line 11 def define(entity_name, *entities) options = entities.last.is_a?(::Hash) ? entities.pop : {} create! entity_name do |entity_klass| entity_klass.entities = entities.map { |entity| Entity[entity] } entity_klass.published = options.fetch(:published, true) end end
new(*args)
click to toggle source
Calls superclass method
# File lib/attentive/composite_entity.rb, line 21 def initialize(*args) super @entities = self.class.entities.map { |entity_klass| entity_klass.new(variable_name) } end
Public Instance Methods
matches?(cursor)
click to toggle source
# File lib/attentive/composite_entity.rb, line 26 def matches?(cursor) entities.each do |entity| match = entity.matches?(cursor) return match if match end false end