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
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/brief/model.rb', line 72
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
64
65
66
|
# File 'lib/brief/model.rb', line 64
def content
document.content
end
|
#data ⇒ Object
60
61
62
|
# File 'lib/brief/model.rb', line 60
def data
document.data || {}.to_mash
end
|
#document_title ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/brief/model.rb', line 52
def document_title
data.try(:[], :title) ||
.try(:title) ||
path.basename.to_s
.gsub(/\.html.md/,'')
.gsub(/\.md/,'')
end
|
#exists? ⇒ Boolean
90
91
92
|
# File 'lib/brief/model.rb', line 90
def exists?
document && document.path && document.path.exist?
end
|
#set_data_attribute(attribute, value) ⇒ Object
84
85
86
87
88
|
# File 'lib/brief/model.rb', line 84
def set_data_attribute(attribute, value)
document.data.send("#{attribute}=", value)
document.save
value
end
|
#title ⇒ Object
48
49
50
|
# File 'lib/brief/model.rb', line 48
def title
document_title
end
|