Class: Orthor::Object

Inherits:
Object
  • Object
show all
Includes:
HttpCaching, MetaData
Defined in:
lib/orthor/object.rb

Direct Known Subclasses

Category, Feed, Page, Query

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HttpCaching

#cache_for

Constructor Details

#initialize(path, options = {}) ⇒ Object

Returns a new instance of Object.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# File 'lib/orthor/object.rb', line 9

def initialize(path, options = {})
  @path = path
  raise ArgumentError, "Path required" unless @path

  options.each { |key, val| send(key, val) }
  @id ||= @path.split("/").last
  @template ||= Orthor::Site.current_template
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/orthor/object.rb', line 6

def path
  @path
end

Instance Method Details

#contentObject



18
19
20
# File 'lib/orthor/object.rb', line 18

def content
  fetch_content
end

#fetch_contentObject



30
31
32
# File 'lib/orthor/object.rb', line 30

def fetch_content
  raise "This must be overriden in any Orthor::Object subclass"
end

#path_nameObject



26
27
28
# File 'lib/orthor/object.rb', line 26

def path_name
  @id.gsub(/[^a-z0-9]+/i, '_')
end

#titleObject



22
23
24
# File 'lib/orthor/object.rb', line 22

def title
  ""
end