Class: Paltrow::Page

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/paltrow/page.rb

Defined Under Namespace

Classes: PageWithURL

Class Method Summary collapse

Instance Method Summary collapse

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

#alertObject



44
45
46
# File 'lib/paltrow/page.rb', line 44

def alert
  failure? ? message : ""
end

#failure?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/paltrow/page.rb', line 36

def failure?
  !success?
end

#noticeObject



40
41
42
# File 'lib/paltrow/page.rb', line 40

def notice
  success? ? message : ""
end

#success?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/paltrow/page.rb', line 32

def success?
  success
end

#to_monadObject



56
57
58
# File 'lib/paltrow/page.rb', line 56

def to_monad
  success? ? Dry::Monads::Success(self) : Dry::Monads::Failure(self)
end

#to_paramsObject



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