Class: QDA::Application

Inherits:
Object
  • Object
show all
Includes:
Broadcaster
Defined in:
lib/weft/application.rb

Constant Summary collapse

SUBSCRIBABLE_EVENTS =
[ :saved, :started, :ended,
:document_added, :document_changed, :document_deleted, 
:category_added, :category_changed, :category_deleted ]

Instance Attribute Summary

Attributes included from Broadcaster

#bc__subscribers, #bc__subscriptions

Instance Method Summary collapse

Methods included from Broadcaster

#add_subscriber, #delete_subscriber, #event_types, #reset_subscriptions

Constructor Details

#initialize(backend_class = nil) ⇒ Application

creates a completely empty new application / project, using the backend backend, to be intialized with args args



39
40
41
# File 'lib/weft/application.rb', line 39

def initialize(backend_class = nil)
     self.extend(backend_class) if backend_class
end

Instance Method Details

#broadcast(evt, content = nil) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/weft/application.rb', line 60

def broadcast(evt, content = nil)
  super(evt, content)
  if evt == :saved or evt == :started or evt == :ended
    @dirty = false
  else
    @dirty = true
  end
end

#dirty?Boolean

are we in a state where we need saving - should be overridden in subclass

Returns:

  • (Boolean)


56
57
58
# File 'lib/weft/application.rb', line 56

def dirty?()
     @dirty
end

#each_docObject



51
52
53
# File 'lib/weft/application.rb', line 51

def each_doc()
  get_all_docs().each { | doc | yield doc }
end

#inspectObject



69
70
71
# File 'lib/weft/application.rb', line 69

def inspect()
  "<QDA::Application>"
end

#set_upObject

create some basic nodes



44
45
46
47
48
49
# File 'lib/weft/application.rb', line 44

def set_up()
  _save_category( Category.new('CATEGORIES', nil) )
  _save_category( Category.new('SEARCHES', nil) )
  save_preference( 'CreateVersion', WEFT_VERSION )
  save_preference( 'CreateVersionString', WEFT_VERSION_STRING )
end