Class: Paltrow::Page
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Paltrow::Page
- Defined in:
- lib/paltrow/page.rb
Defined Under Namespace
Classes: PageWithURL
Class Method Summary collapse
Instance Method Summary collapse
- #alert ⇒ Object
- #failure? ⇒ Boolean
- #notice ⇒ Object
- #success? ⇒ Boolean
- #to_monad ⇒ Object
- #to_params ⇒ Object
- #with_alert(an_alert) ⇒ Object
- #with_notice(a_notice) ⇒ Object
Class Method Details
.with_url(url) ⇒ Object
22 23 24 |
# File 'lib/paltrow/page.rb', line 22 def self.with_url(url) PageWithURL.new(to_params: url) end |
Instance Method Details
#alert ⇒ Object
44 45 46 |
# File 'lib/paltrow/page.rb', line 44 def alert failure? ? : "" end |
#failure? ⇒ Boolean
36 37 38 |
# File 'lib/paltrow/page.rb', line 36 def failure? !success? end |
#notice ⇒ Object
40 41 42 |
# File 'lib/paltrow/page.rb', line 40 def notice success? ? : "" end |
#success? ⇒ Boolean
32 33 34 |
# File 'lib/paltrow/page.rb', line 32 def success? success end |
#to_monad ⇒ Object
56 57 58 |
# File 'lib/paltrow/page.rb', line 56 def to_monad success? ? Dry::Monads::Success(self) : Dry::Monads::Failure(self) end |
#to_params ⇒ Object
26 27 28 29 30 |
# File 'lib/paltrow/page.rb', line 26 def to_params {resource: resource, action: action} .merge(query) .merge(resource_ids) end |
#with_alert(an_alert) ⇒ Object
52 53 54 |
# File 'lib/paltrow/page.rb', line 52 def with_alert an_alert new(message: an_alert, success: false) end |
#with_notice(a_notice) ⇒ Object
48 49 50 |
# File 'lib/paltrow/page.rb', line 48 def with_notice a_notice new(message: a_notice, success: true) end |