Class: Entitled::Titles
- Inherits:
-
Object
- Object
- Entitled::Titles
- Defined in:
- lib/entitled/entitled.rb
Constant Summary collapse
- DEFAULT_TITLES_PER_PAGE =
1
Class Attribute Summary collapse
-
.per_page ⇒ Object
Returns the value of attribute per_page.
-
.prefix_exceptions ⇒ Object
Returns the value of attribute prefix_exceptions.
-
.site_title ⇒ Object
Returns the value of attribute site_title.
Instance Attribute Summary collapse
-
#breadcrumbs ⇒ Object
readonly
Returns the value of attribute breadcrumbs.
-
#headings ⇒ Object
readonly
Returns the value of attribute headings.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#up ⇒ Object
readonly
Returns the value of attribute up.
Instance Method Summary collapse
- #add(*objects) ⇒ Object
- #add_collection(class_name, first) ⇒ Object
- #add_resource(resource_or_string) ⇒ Object
- #generate(view) ⇒ Object
-
#initialize(controller) ⇒ Titles
constructor
A new instance of Titles.
- #resource_class?(klass_name) ⇒ Boolean
- #resources? ⇒ Boolean
Constructor Details
#initialize(controller) ⇒ Titles
Returns a new instance of Titles.
140 141 142 143 144 |
# File 'lib/entitled/entitled.rb', line 140 def initialize controller @controller = controller @titles = [] @resources_titles = [] end |
Class Attribute Details
.per_page ⇒ Object
Returns the value of attribute per_page.
135 136 137 |
# File 'lib/entitled/entitled.rb', line 135 def per_page @per_page end |
.prefix_exceptions ⇒ Object
Returns the value of attribute prefix_exceptions.
135 136 137 |
# File 'lib/entitled/entitled.rb', line 135 def prefix_exceptions @prefix_exceptions end |
.site_title ⇒ Object
Returns the value of attribute site_title.
135 136 137 |
# File 'lib/entitled/entitled.rb', line 135 def site_title @site_title end |
Instance Attribute Details
#breadcrumbs ⇒ Object (readonly)
Returns the value of attribute breadcrumbs.
137 138 139 |
# File 'lib/entitled/entitled.rb', line 137 def @breadcrumbs end |
#headings ⇒ Object (readonly)
Returns the value of attribute headings.
137 138 139 |
# File 'lib/entitled/entitled.rb', line 137 def headings @headings end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
137 138 139 |
# File 'lib/entitled/entitled.rb', line 137 def tag @tag end |
#up ⇒ Object (readonly)
Returns the value of attribute up.
137 138 139 |
# File 'lib/entitled/entitled.rb', line 137 def up @up end |
Instance Method Details
#add(*objects) ⇒ Object
164 165 166 |
# File 'lib/entitled/entitled.rb', line 164 def add *objects objects.each { |object| @titles << ResourceTitle.new(object) } end |
#add_collection(class_name, first) ⇒ Object
154 155 156 |
# File 'lib/entitled/entitled.rb', line 154 def add_collection class_name, first @titles << CollectionTitle.new(class_name, first) end |
#add_resource(resource_or_string) ⇒ Object
158 159 160 161 162 |
# File 'lib/entitled/entitled.rb', line 158 def add_resource resource_or_string resource_title = ResourceTitle.new(resource_or_string) @titles << resource_title @resources_titles << resource_title if resource_title.resource? end |
#generate(view) ⇒ Object
146 147 148 149 150 151 152 |
# File 'lib/entitled/entitled.rb', line 146 def generate view @view = view add_title_for_new_or_create @breadcrumbs = compact_titles(@titles) @headings = compact_titles(page_titles, false) @tag = generate_tag end |
#resource_class?(klass_name) ⇒ Boolean
172 173 174 175 |
# File 'lib/entitled/entitled.rb', line 172 def resource_class? klass_name @resources_titles.each { |title| return title.resource if title.resource.class.name == klass_name } false end |
#resources? ⇒ Boolean
168 169 170 |
# File 'lib/entitled/entitled.rb', line 168 def resources? @resources_titles.any? end |