Class: PositronicBrain::Base
- Inherits:
-
Object
- Object
- PositronicBrain::Base
- Defined in:
- lib/positronic_brain/base.rb
Direct Known Subclasses
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#persistence ⇒ Object
Returns the value of attribute persistence.
Class Method Summary collapse
- .initialize_persistence(path, options = {}) ⇒ Object
- .persistence(klass, options = {}) ⇒ Object
- .persistence_class ⇒ Object
- .persistence_options ⇒ Object
Instance Method Summary collapse
- #dump_path ⇒ Object
-
#initialize(namespace, options = {}) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
Constructor Details
#initialize(namespace, options = {}) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/positronic_brain/base.rb', line 8 def initialize(namespace, = {}) @namespace = namespace @persistence = self.class.initialize_persistence(dump_path, [:persistence] || {}) end |
Class Attribute Details
.dump_name ⇒ Object
25 26 27 |
# File 'lib/positronic_brain/base.rb', line 25 def dump_name @dump_name || self.name.gsub(/^.*\:\:/, '').underscore end |
.dump_path ⇒ Object
29 30 31 |
# File 'lib/positronic_brain/base.rb', line 29 def dump_path @dump_path || self.superclass.dump_path end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
3 4 5 |
# File 'lib/positronic_brain/base.rb', line 3 def namespace @namespace end |
#persistence ⇒ Object
Returns the value of attribute persistence.
4 5 6 |
# File 'lib/positronic_brain/base.rb', line 4 def persistence @persistence end |
Class Method Details
.initialize_persistence(path, options = {}) ⇒ Object
45 46 47 |
# File 'lib/positronic_brain/base.rb', line 45 def initialize_persistence(path, = {}) persistence_class.new path, .merge() end |
.persistence(klass, options = {}) ⇒ Object
41 42 43 |
# File 'lib/positronic_brain/base.rb', line 41 def persistence(klass, = {}) @persistence_class, @persistence_options = klass, end |
.persistence_class ⇒ Object
33 34 35 |
# File 'lib/positronic_brain/base.rb', line 33 def persistence_class @persistence_class || self.superclass.persistence_class end |
.persistence_options ⇒ Object
37 38 39 |
# File 'lib/positronic_brain/base.rb', line 37 def @persistence_options || self.superclass. end |
Instance Method Details
#dump_path ⇒ Object
13 14 15 16 |
# File 'lib/positronic_brain/base.rb', line 13 def dump_path path_parts = [self.class.dump_path, self.class.dump_name, "#{@namespace}.marshal"].compact File.join *path_parts end |
#inspect ⇒ Object
18 19 20 |
# File 'lib/positronic_brain/base.rb', line 18 def inspect "#<#{self.class.name} #{namespace}>" end |