Class: Trundle::TextBundle
- Inherits:
-
Object
- Object
- Trundle::TextBundle
show all
- Extended by:
- InfoAccessors
- Defined in:
- lib/trundle/text_bundle.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
info_accessors
Constructor Details
Returns a new instance of TextBundle.
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/trundle/text_bundle.rb', line 14
def initialize(path)
@path = path
@info_store = Trundle::InfoStore.new(File.join(@path, 'info.json'))
@text_store = Trundle::TextStore.new(File.join(@path, 'text.markdown'))
@asset_store = Trundle::AssetStore.new(File.join(@path, 'assets'))
@info_store.content = Trundle.config.to_h unless exist?
if block_given?
yield(self)
close
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/trundle/text_bundle.rb', line 60
def method_missing(name, *args, &block)
if Trundle.config.namespace?(name)
namespaced_attributes_for(name)
else
raise Trundle::NamespaceNotDefined, namespace_not_defined_message(name)
end
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
4
5
6
|
# File 'lib/trundle/text_bundle.rb', line 4
def path
@path
end
|
Instance Method Details
#assets ⇒ Object
40
41
42
|
# File 'lib/trundle/text_bundle.rb', line 40
def assets
@asset_store
end
|
#close ⇒ Object
44
45
46
47
48
49
|
# File 'lib/trundle/text_bundle.rb', line 44
def close
Dir.mkdir(@path) unless exist?
write_namespaces
@info_store.write
@text_store.write
end
|
#exist? ⇒ Boolean
28
29
30
|
# File 'lib/trundle/text_bundle.rb', line 28
def exist?
File.exist?(@path)
end
|
#text ⇒ Object
32
33
34
|
# File 'lib/trundle/text_bundle.rb', line 32
def text
@text_store.content
end
|
#text=(value) ⇒ Object
36
37
38
|
# File 'lib/trundle/text_bundle.rb', line 36
def text=(value)
@text_store.content = value
end
|
#transient=(value) ⇒ Object
51
52
53
54
|
# File 'lib/trundle/text_bundle.rb', line 51
def transient=(value)
raise ArgumentError, 'transient must be a boolean' unless !!value == value
info['transient'] = value
end
|
#transient? ⇒ Boolean
56
57
58
|
# File 'lib/trundle/text_bundle.rb', line 56
def transient?
!!info['transient']
end
|