Class: Plutonium::Action::RouteOptions
- Inherits:
-
Object
- Object
- Plutonium::Action::RouteOptions
- Defined in:
- lib/plutonium/action/route_options.rb
Overview
RouteOptions class for handling routing options in the Plutonium framework.
Instance Attribute Summary collapse
-
#method ⇒ Symbol
readonly
The HTTP method for the route.
-
#url_args ⇒ Array
readonly
The positional arguments for URL generation.
-
#url_options ⇒ Hash
readonly
URL options for the route.
-
#url_resolver ⇒ Symbol
readonly
The method to use for resolving URLs.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(*url_args, method: :get, url_resolver: :resource_url_for, **url_options) ⇒ RouteOptions
constructor
Initialize a new RouteOptions instance.
-
#merge(other) ⇒ RouteOptions
Merge this RouteOptions with another RouteOptions instance.
-
#to_url_args ⇒ Array
Convert the RouteOptions to arguments suitable for URL helpers.
Constructor Details
#initialize(*url_args, method: :get, url_resolver: :resource_url_for, **url_options) ⇒ RouteOptions
Initialize a new RouteOptions instance.
20 21 22 23 24 25 26 |
# File 'lib/plutonium/action/route_options.rb', line 20 def initialize(*url_args, method: :get, url_resolver: :resource_url_for, **) @method = method @url_resolver = url_resolver @url_args = url_args @url_options = .freeze freeze end |
Instance Attribute Details
#method ⇒ Symbol (readonly)
The HTTP method for the route.
11 12 13 |
# File 'lib/plutonium/action/route_options.rb', line 11 def method @method end |
#url_args ⇒ Array (readonly)
The positional arguments for URL generation.
11 12 13 |
# File 'lib/plutonium/action/route_options.rb', line 11 def url_args @url_args end |
#url_options ⇒ Hash (readonly)
URL options for the route.
11 12 13 |
# File 'lib/plutonium/action/route_options.rb', line 11 def @url_options end |
#url_resolver ⇒ Symbol (readonly)
The method to use for resolving URLs.
11 12 13 |
# File 'lib/plutonium/action/route_options.rb', line 11 def url_resolver @url_resolver end |
Instance Method Details
#==(other) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/plutonium/action/route_options.rb', line 48 def ==(other) self.class == other.class && method == other.method && url_resolver == other.url_resolver && url_args == other.url_args && == other. end |
#eql?(other) ⇒ Boolean
56 57 58 |
# File 'lib/plutonium/action/route_options.rb', line 56 def eql?(other) self == other end |
#hash ⇒ Object
60 61 62 |
# File 'lib/plutonium/action/route_options.rb', line 60 def hash [self.class, method, url_resolver, url_args, ].hash end |
#merge(other) ⇒ RouteOptions
Merge this RouteOptions with another RouteOptions instance.
39 40 41 42 43 44 45 46 |
# File 'lib/plutonium/action/route_options.rb', line 39 def merge(other) self.class.new( *(@url_args | other.url_args), method: other.method || @method, url_resolver: other.url_resolver || @url_resolver, **@url_options.merge(other.) ) end |
#to_url_args ⇒ Array
Convert the RouteOptions to arguments suitable for URL helpers.
31 32 33 |
# File 'lib/plutonium/action/route_options.rb', line 31 def to_url_args @url_args + [@url_options] end |