Module: Viewable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Block, Form, Image, Link, Page, Select, String, Text
- Defined in:
- app/models/viewable.rb,
app/models/viewable/form.rb,
app/models/viewable/link.rb,
app/models/viewable/page.rb,
app/models/viewable/text.rb,
app/models/viewable/block.rb,
app/models/viewable/image.rb,
app/models/viewable/select.rb,
app/models/viewable/string.rb,
app/models/viewable/field/url.rb,
app/models/viewable/field/uuid.rb,
app/presenters/viewable/form_presenter.rb,
app/presenters/viewable/link_presenter.rb,
app/presenters/viewable/page_presenter.rb,
app/presenters/viewable/text_presenter.rb,
app/presenters/viewable/view_presenter.rb,
app/presenters/viewable/block_presenter.rb,
app/presenters/viewable/image_presenter.rb,
app/presenters/viewable/select_presenter.rb,
app/presenters/viewable/link_list_presenter.rb,
app/presenters/viewable/select_list_presenter.rb
Defined Under Namespace
Modules: Field
Classes: Block, BlockPresenter, Form, FormPresenter, Image, ImagePresenter, Link, LinkListPresenter, LinkPresenter, Page, PagePresenter, Select, SelectListPresenter, SelectPresenter, String, Text, TextPresenter, ViewPresenter
Instance Method Summary
collapse
Instance Method Details
#list(locale = nil) ⇒ Object
46
47
48
49
50
|
# File 'app/models/viewable.rb', line 46
def list(locale = nil)
self.class.includes(:unique_key)
.where(unique_keys: { viewable_type: viewable_type, view_path: view_path, name: unique_key_name })
.where(unique_keys: { locale: locale || self.locale })
end
|
#other_locales(position = nil) ⇒ Object
52
53
54
55
56
57
|
# File 'app/models/viewable.rb', line 52
def other_locales(position = nil)
self.class.includes(:unique_key)
.where(unique_keys: { viewable_type: viewable_type, view_path: view_path, name: unique_key_name })
.where(unique_keys: { position: position || self.position })
.where.not(unique_keys: { locale: locale })
end
|
#unique_key_hash(locale = nil) ⇒ Object
59
60
61
62
63
|
# File 'app/models/viewable.rb', line 59
def unique_key_hash(locale = nil)
unique_key
.slice(:viewable_type, :view_path, :name, :position)
.merge(locale: locale || self.locale)
end
|