Class: MuchRails::Action::BaseRouter::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/much-rails/action/base_router.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_method:, url:, default_action_class_name:, request_type_actions:, called_from:, default_params: nil) ⇒ Definition

Returns a new instance of Definition.



444
445
446
447
448
449
450
451
452
453
454
455
456
457
# File 'lib/much-rails/action/base_router.rb', line 444

def initialize(
      http_method:,
      url:,
      default_action_class_name:,
      request_type_actions:,
      called_from:,
      default_params: nil)
  @http_method = http_method
  @url = url
  @default_params = default_params || {}
  @default_action_class_name = default_action_class_name
  @request_type_actions = request_type_actions || []
  @called_from = called_from
end

Instance Attribute Details

#called_fromObject (readonly)

Returns the value of attribute called_from.



442
443
444
# File 'lib/much-rails/action/base_router.rb', line 442

def called_from
  @called_from
end

#default_action_class_nameObject (readonly)

Returns the value of attribute default_action_class_name.



441
442
443
# File 'lib/much-rails/action/base_router.rb', line 441

def default_action_class_name
  @default_action_class_name
end

#default_paramsObject (readonly)

Returns the value of attribute default_params.



440
441
442
# File 'lib/much-rails/action/base_router.rb', line 440

def default_params
  @default_params
end

#http_methodObject (readonly)

Returns the value of attribute http_method.



440
441
442
# File 'lib/much-rails/action/base_router.rb', line 440

def http_method
  @http_method
end

#request_type_actionsObject (readonly)

Returns the value of attribute request_type_actions.



441
442
443
# File 'lib/much-rails/action/base_router.rb', line 441

def request_type_actions
  @request_type_actions
end

#urlObject (readonly)

Returns the value of attribute url.



440
441
442
# File 'lib/much-rails/action/base_router.rb', line 440

def url
  @url
end

Class Method Details

.for_route(http_method:, url:, default_action_class_name:, request_type_actions:, called_from:) ⇒ Object



425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/much-rails/action/base_router.rb', line 425

def self.for_route(
      http_method:,
      url:,
      default_action_class_name:,
      request_type_actions:,
      called_from:)
  new(
    http_method: http_method,
    url: url,
    default_action_class_name: default_action_class_name,
    request_type_actions: request_type_actions,
    called_from: called_from,
  )
end

Instance Method Details

#==(other) ⇒ Object



481
482
483
484
485
486
487
488
489
490
# File 'lib/much-rails/action/base_router.rb', line 481

def ==(other)
  return super unless other.is_a?(self.class)

  @http_method == other.http_method &&
  @url == other.url &&
  @default_params == other.default_params &&
  @default_action_class_name ==
    other.default_action_class_name &&
  @request_type_actions == other.request_type_actions
end

#default_action_class_constantObject



471
472
473
474
475
# File 'lib/much-rails/action/base_router.rb', line 471

def default_action_class_constant
  return unless has_default_action_class_name?

  @default_action_class_constant ||= default_action_class_name.constantize
end

#default_action_formatObject



477
478
479
# File 'lib/much-rails/action/base_router.rb', line 477

def default_action_format
  default_action_class_constant&.format
end

#has_default_action_class_name?Boolean

Returns:



467
468
469
# File 'lib/much-rails/action/base_router.rb', line 467

def has_default_action_class_name?
  !@default_action_class_name.nil?
end

#nameObject



459
460
461
# File 'lib/much-rails/action/base_router.rb', line 459

def name
  @url.name
end

#pathObject



463
464
465
# File 'lib/much-rails/action/base_router.rb', line 463

def path
  @url.path
end