Sha256: f9d81c4e9617093d8bfd353be12d6a3a5ac02bbcf3c4cb93ab0c7283ad9c3a35
Contents?: true
Size: 865 Bytes
Versions: 4
Compression:
Stored size: 865 Bytes
Contents
# Models a controller action. To be used within the block of a WUI. require 'katapult/element' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/string/inquiry' module Katapult class Action < Element options :method, :scope def initialize(*args) super self.scope ||= (name == 'index') ? :collection : :member set_method end delegate :post?, :get?, :put?, to: :method_inquiry delegate :member?, :collection?, to: :scope_inquiry private def method_inquiry @method.to_s.inquiry end def scope_inquiry @scope.to_s.inquiry end def set_method self.method ||= case name when 'create', 'update' :post when 'destroy' :delete else # index, show, new, edit + custom actions :get end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
katapult-0.2.0 | lib/katapult/action.rb |
katapult-0.1.2 | lib/katapult/action.rb |
katapult-0.1.1 | lib/katapult/action.rb |
katapult-0.1.0 | lib/katapult/action.rb |