Class: Social::Determinant::SocialPrefix::Provider
- Inherits:
-
Object
- Object
- Social::Determinant::SocialPrefix::Provider
- Defined in:
- lib/social/determinant/social_prefix.rb
Overview
Класс провайдерa для обеспечения social-prefix, принимает prefix от builder’a и подмешивает social_env в параметры запроса
Class Method Summary collapse
Class Method Details
.build(prefix) ⇒ Class
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/social/determinant/social_prefix.rb', line 28 def self.build(prefix) klass = Class.new do class << self attr_accessor :prefix end def initialize(app) @app = app end def call(env) request = Rack::Request.new(env) prefix = self.class.prefix type = Social.type_by_prefix(prefix) id = Social.id_by_type(type) request.GET['social_env'] = { 'prefix' => prefix, 'type' => type, 'id' => id } @app.call(request.env) end end klass.prefix = prefix klass end |