Class: ActionFacade::Base
- Inherits:
-
Object
- Object
- ActionFacade::Base
- Defined in:
- lib/action_facade/base.rb
Overview
Action Facade Base
This is only a base class for extract data from input (payload). This can be inherited to another class and you can implement some mothods for obtaining data. In Ruby on Rails, you can implemented Active Record query methods to the inherited class. For example
class Mypage::IndexFacade < ActionFacade::Base
attr_reader :current_user
def initialize(payload)
@current_user = payload[:current_user]
end
def active_users
@active_users ||= User.active.order(login_at: :desc).limit(10)
end
def
@messages ||= current_user..order(created_at: :desc).limit(10)
end
end
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(payload = {}) ⇒ Base
constructor
Initialize with payload.
Constructor Details
#initialize(payload = {}) ⇒ Base
Initialize with payload
33 34 35 |
# File 'lib/action_facade/base.rb', line 33 def initialize(payload = {}) @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
30 31 32 |
# File 'lib/action_facade/base.rb', line 30 def payload @payload end |