Class: DefaultActions
- Inherits:
-
Object
- Object
- DefaultActions
- Defined in:
- lib/whales_dispatch/default_actions.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
-
#initialize(resource) ⇒ DefaultActions
constructor
A new instance of DefaultActions.
- #new ⇒ Object
- #parse_action_restrictions(restrictions_hash) ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(resource) ⇒ DefaultActions
Returns a new instance of DefaultActions.
3 4 5 6 7 |
# File 'lib/whales_dispatch/default_actions.rb', line 3 def initialize(resource) @resource = resource.to_s @resource_id = @resource.singularize + "_id" @actions = all end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
2 3 4 |
# File 'lib/whales_dispatch/default_actions.rb', line 2 def actions @actions end |
Instance Method Details
#create ⇒ Object
27 28 29 |
# File 'lib/whales_dispatch/default_actions.rb', line 27 def create { create: { suffix: "$", method: :post } } end |
#destroy ⇒ Object
39 40 41 |
# File 'lib/whales_dispatch/default_actions.rb', line 39 def destroy { destroy: { suffix: "/(?<#{@resource_id}>\\d+)$", method: :delete } } end |
#edit ⇒ Object
31 32 33 |
# File 'lib/whales_dispatch/default_actions.rb', line 31 def edit { edit: { suffix: "/(?<#{@resource_id}>\\d+)/edit$", method: :get } } end |
#index ⇒ Object
15 16 17 |
# File 'lib/whales_dispatch/default_actions.rb', line 15 def index { index: { suffix: "$", method: :get } } end |
#new ⇒ Object
23 24 25 |
# File 'lib/whales_dispatch/default_actions.rb', line 23 def new { new: { suffix: "/new$", method: :get } } end |
#parse_action_restrictions(restrictions_hash) ⇒ Object
9 10 11 12 13 |
# File 'lib/whales_dispatch/default_actions.rb', line 9 def parse_action_restrictions(restrictions_hash) raise(ArgumentError) if restrictions_hash.size > 1 send(:only, restrictions_hash[:only]) if restrictions_hash[:only] send(:except, restrictions_hash[:except]) if restrictions_hash[:except] end |
#show ⇒ Object
19 20 21 |
# File 'lib/whales_dispatch/default_actions.rb', line 19 def show { show: { suffix: "/(?<#{@resource_id}>\\d+)$", method: :post } } end |
#update ⇒ Object
35 36 37 |
# File 'lib/whales_dispatch/default_actions.rb', line 35 def update { update: { suffix: "/(?<#{@resource_id}>\\d+)$", method: :put } } end |