Class: Subledger::Domain::Category

Direct Known Subclasses

ActiveCategory, ArchivedCategory

Defined Under Namespace

Classes: Entity

Instance Attribute Summary collapse

Attributes included from Roles::Versionable

#version

Attributes included from Roles::Storable

#client, #store

Attributes included from Roles::Identifiable

#id

Attributes included from Roles::Describable

#description, #reference

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Roles::Restable

#patch_hash, #post_hash, #serializable_hash, #to_json

Methods included from Roles::Archivable

#archive

Methods included from Roles::Activatable

#activate

Methods included from Roles::Collectable

included

Methods included from Roles::Updatable

included, #update

Methods included from Roles::Readable

included, #read

Methods included from Roles::Creatable

#create, included

Methods included from Roles::Versionable

included

Methods included from Roles::Attributable

#attributes

Methods included from Subledger::Domain

#==, #collection_name, #entity_name, included, #to_s

Constructor Details

#initialize(args) ⇒ Category

Returns a new instance of Category.



53
54
55
56
57
58
59
60
61
# File 'lib/subledger/domain/category.rb', line 53

def initialize args
  describable args
  identifiable args
  storable args
  versionable args

  @book           = args[:book]
  @normal_balance = args[:normal_balance]
end

Instance Attribute Details

#bookObject (readonly)

Returns the value of attribute book.



26
27
28
# File 'lib/subledger/domain/category.rb', line 26

def book
  @book
end

#normal_balanceObject

Returns the value of attribute normal_balance.



27
28
29
# File 'lib/subledger/domain/category.rb', line 27

def normal_balance
  @normal_balance
end

Class Method Details

.active_klassObject



45
46
47
# File 'lib/subledger/domain/category.rb', line 45

def self.active_klass
  ActiveCategory
end

.archived_klassObject



49
50
51
# File 'lib/subledger/domain/category.rb', line 49

def self.archived_klass
  ArchivedCategory
end

.patch_keysObject



33
34
35
# File 'lib/subledger/domain/category.rb', line 33

def self.patch_keys
  [ :id, :description, :reference, :normal_balance, :version ]
end

.post_keysObject



29
30
31
# File 'lib/subledger/domain/category.rb', line 29

def self.post_keys
  [ :description, :reference, :normal_balance ]
end

.root_klassObject



37
38
39
# File 'lib/subledger/domain/category.rb', line 37

def self.root_klass
  Category
end

.sub_klassesObject



41
42
43
# File 'lib/subledger/domain/category.rb', line 41

def self.sub_klasses
  [ active_klass, archived_klass ]
end

Instance Method Details

#accounts(&block) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/subledger/domain/category.rb', line 63

def accounts &block
  begin
    store.collect_accounts_for_category self, &block
  rescue Store::CollectError => e
    raise CategoryError, e
  end
end