Class: Smartdown::Model::FrontMatter
- Inherits:
-
Object
- Object
- Smartdown::Model::FrontMatter
show all
- Defined in:
- lib/smartdown/model/front_matter.rb
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ FrontMatter
Returns a new instance of FrontMatter.
4
5
6
|
# File 'lib/smartdown/model/front_matter.rb', line 4
def initialize(attributes = {})
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/smartdown/model/front_matter.rb', line 8
def method_missing(method_name, *args, &block)
if has_attribute?(method_name)
fetch(method_name)
else
super
end
end
|
Instance Method Details
#==(other) ⇒ Object
32
33
34
|
# File 'lib/smartdown/model/front_matter.rb', line 32
def ==(other)
other.is_a?(self.class) && self.to_hash == other.to_hash
end
|
#fetch(name) ⇒ Object
24
25
26
|
# File 'lib/smartdown/model/front_matter.rb', line 24
def fetch(name)
@attributes.fetch(name.to_s)
end
|
#has_attribute?(name) ⇒ Boolean
20
21
22
|
# File 'lib/smartdown/model/front_matter.rb', line 20
def has_attribute?(name)
@attributes.has_key?(name.to_s)
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
16
17
18
|
# File 'lib/smartdown/model/front_matter.rb', line 16
def respond_to_missing?(method_name, include_private = false)
has_attribute?(method_name)
end
|
#to_hash ⇒ Object
28
29
30
|
# File 'lib/smartdown/model/front_matter.rb', line 28
def to_hash
@attributes.dup
end
|