Class: Yoda::Store::Objects::Base
Abstract
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#derive, included, #to_json
Constructor Details
#initialize(path:, document: '', tag_list: [], sources: [], primary_source: nil, json_class: nil, kind: nil) ⇒ Base
Returns a new instance of Base.
37
38
39
40
41
42
43
|
# File 'lib/yoda/store/objects/base.rb', line 37
def initialize(path:, document: '', tag_list: [], sources: [], primary_source: nil, json_class: nil, kind: nil)
@path = path
@document = document
@tag_list = tag_list
@sources = sources
@primary_source = primary_source
end
|
Instance Attribute Details
#document ⇒ String
21
22
23
|
# File 'lib/yoda/store/objects/base.rb', line 21
def document
@document
end
|
#path ⇒ String
18
19
20
|
# File 'lib/yoda/store/objects/base.rb', line 18
def path
@path
end
|
#primary_source ⇒ (String, Integer, Integer)?
30
31
32
|
# File 'lib/yoda/store/objects/base.rb', line 30
def primary_source
@primary_source
end
|
#sources ⇒ Array<(String, Integer, Integer)>
27
28
29
|
# File 'lib/yoda/store/objects/base.rb', line 27
def sources
@sources
end
|
#tag_list ⇒ Array<Tag>
24
25
26
|
# File 'lib/yoda/store/objects/base.rb', line 24
def tag_list
@tag_list
end
|
Class Method Details
.attr_names ⇒ Array<Symbol>
12
13
14
|
# File 'lib/yoda/store/objects/base.rb', line 12
def attr_names
%i(path document tag_list sources primary_source)
end
|
Instance Method Details
#==(another) ⇒ Object
86
87
88
|
# File 'lib/yoda/store/objects/base.rb', line 86
def ==(another)
eql?(another)
end
|
#address ⇒ String
56
57
58
|
# File 'lib/yoda/store/objects/base.rb', line 56
def address
path
end
|
#eql?(another) ⇒ Boolean
82
83
84
|
# File 'lib/yoda/store/objects/base.rb', line 82
def eql?(another)
self.class == another.class && to_h == another.to_h
end
|
#hash ⇒ Object
78
79
80
|
# File 'lib/yoda/store/objects/base.rb', line 78
def hash
([self.class.name] + to_h.to_a).hash
end
|
#kind ⇒ Symbol
51
52
53
|
# File 'lib/yoda/store/objects/base.rb', line 51
def kind
fail NotImplementedError
end
|
#merge(another) ⇒ self
74
75
76
|
# File 'lib/yoda/store/objects/base.rb', line 74
def merge(another)
self.class.new(merge_attributes(another))
end
|
#name ⇒ String
46
47
48
|
# File 'lib/yoda/store/objects/base.rb', line 46
def name
fail NotImplementedError
end
|
#to_h ⇒ Hash
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/yoda/store/objects/base.rb', line 61
def to_h
{
kind: kind,
path: path,
document: document,
tag_list: tag_list,
sources: sources,
primary_source: primary_source
}
end
|