Class: UserPlane::RouteConcerns::Base

Inherits:
AbstractNamespacedConcern show all
Defined in:
lib/user_plane/route_concerns.rb

Overview

Defines two resources: A session resource to sign a user in and out A details resource to let a user change the account’s details It also defines an extra concern And a signed_in routing concern to ensure that child routes are accessible only to signed in users. It defines a route to edit the account details and one to sign in and sign out.

To enforce being singed in to certain resources: resource :score, concern: :signed_in

scope ‘/profile’ concern: :signed_in do

resource :score
resource :buddies

end

Instance Attribute Summary collapse

Attributes inherited from AbstractConcern

#concern_options, #mapper

Instance Method Summary collapse

Methods inherited from AbstractNamespacedConcern

#call

Methods inherited from AbstractConcern

#call, #exists?, #initialize, #options

Constructor Details

This class inherits a constructor from UserPlane::RouteConcerns::AbstractConcern

Instance Attribute Details

#singed_in_constraintObject

Returns the value of attribute singed_in_constraint.



76
77
78
# File 'lib/user_plane/route_concerns.rb', line 76

def singed_in_constraint
  @singed_in_constraint
end

Instance Method Details

#buildObject



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/user_plane/route_concerns.rb', line 78

def build
  mapper.resource :sign_in, options(only: [:new, :create, :destroy]) do
    if exists? :auth_endpoint
      mapper.concerns :auth_endpoint, controller: :sign_ins
    end
  end

  mapper.resource :details, options(only: [:edit, :update],
                                    as: :update_details,
                                    constraints: RouteConcerns.signed_in_constraint)
end