Module: Brief::Model::AccessorMethods
- Defined in:
- lib/brief/model.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/brief/model.rb', line 57
def method_missing(meth, *args, &block)
if args.empty?
if document.respond_to?(meth)
document.send(meth, *args, &block)
else
document.data && document.data.key?(meth) ? data[meth] : .send(meth)
end
else
super
end
end
|
Instance Method Details
#content ⇒ Object
49
50
51
|
# File 'lib/brief/model.rb', line 49
def content
document.content
end
|
#data ⇒ Object
45
46
47
|
# File 'lib/brief/model.rb', line 45
def data
document.data || {}.to_mash
end
|
#document_title ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/brief/model.rb', line 37
def document_title
data.try(:[], :title) ||
.try(:title) ||
path.basename.to_s
.gsub(/\.html.md/,'')
.gsub(/\.md/,'')
end
|
#exists? ⇒ Boolean
69
70
71
|
# File 'lib/brief/model.rb', line 69
def exists?
document && document.path && document.path.exist?
end
|
#title ⇒ Object
33
34
35
|
# File 'lib/brief/model.rb', line 33
def title
document_title
end
|