Class: ActivePermalink::Querying::PermalinkLocator
- Inherits:
-
Object
- Object
- ActivePermalink::Querying::PermalinkLocator
- Defined in:
- lib/active_permalink/querying.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(model, options) ⇒ PermalinkLocator
constructor
A new instance of PermalinkLocator.
- #locate(*args) ⇒ Object
- #locate!(*args) ⇒ Object
- #scope(value, locale: nil) ⇒ Object
Constructor Details
#initialize(model, options) ⇒ PermalinkLocator
Returns a new instance of PermalinkLocator.
42 43 44 45 |
# File 'lib/active_permalink/querying.rb', line 42 def initialize(model, ) @model = model @options = end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
40 41 42 |
# File 'lib/active_permalink/querying.rb', line 40 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
40 41 42 |
# File 'lib/active_permalink/querying.rb', line 40 def @options end |
Instance Method Details
#locate(*args) ⇒ Object
52 53 54 |
# File 'lib/active_permalink/querying.rb', line 52 def locate(*args) find_record(:find_by, *args) end |
#locate!(*args) ⇒ Object
56 57 58 |
# File 'lib/active_permalink/querying.rb', line 56 def locate!(*args) find_record(:find_by!, *args) end |
#scope(value, locale: nil) ⇒ Object
47 48 49 50 |
# File 'lib/active_permalink/querying.rb', line 47 def scope(value, locale: nil) params = localize(slug: value, locale: locale) model.joins(:permalinks).where(permalinks: params) end |