Class: Seiten::Navigation
- Inherits:
-
Object
- Object
- Seiten::Navigation
- Defined in:
- lib/seiten/navigation.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#name ⇒ Object
Returns the value of attribute name.
-
#page_collection ⇒ Object
Returns the value of attribute page_collection.
Class Method Summary collapse
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(options = {}) ⇒ Navigation
constructor
A new instance of Navigation.
- #pages ⇒ Object
- #pages=(pages_array) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Navigation
Returns a new instance of Navigation.
5 6 7 8 9 10 11 |
# File 'lib/seiten/navigation.rb', line 5 def initialize(={}) @name = [:name].to_s @locale = [:locale].to_s @config = [:config] || File.join(Rails.root, Seiten.config[:config_dir], "#{id}.yml") @dir = [:dir] || File.join(Rails.root, Seiten.config[:pages_dir], @name, @locale) @page_collection = Seiten::PageCollection.new(navigation_id: id) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/seiten/navigation.rb', line 3 def config @config end |
#dir ⇒ Object
Returns the value of attribute dir.
3 4 5 |
# File 'lib/seiten/navigation.rb', line 3 def dir @dir end |
#locale ⇒ Object
Returns the value of attribute locale.
3 4 5 |
# File 'lib/seiten/navigation.rb', line 3 def locale @locale end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/seiten/navigation.rb', line 3 def name @name end |
#page_collection ⇒ Object
Returns the value of attribute page_collection.
3 4 5 |
# File 'lib/seiten/navigation.rb', line 3 def page_collection @page_collection end |
Class Method Details
.find_by(params = {}) ⇒ Object
14 15 16 |
# File 'lib/seiten/navigation.rb', line 14 def find_by(params={}) where(params).first end |
.where(params = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/seiten/navigation.rb', line 18 def where(params={}) Seiten..select do || params.all? do |param| .send(param[0]) == param[1] end end end |
Instance Method Details
#id ⇒ Object
27 28 29 |
# File 'lib/seiten/navigation.rb', line 27 def id "%s.%s" % [name, locale] end |
#pages ⇒ Object
31 32 33 |
# File 'lib/seiten/navigation.rb', line 31 def pages page_collection end |
#pages=(pages_array) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/seiten/navigation.rb', line 35 def pages=(pages_array) page_collection.pages = pages_array.map { |page| page. = id; page } # return page_collection # NOTE: This doesn't work and just returns page_array. # I think because page_collection#pages= attr_accessor is called first # and thus why our return call is ignored. end |