Module: Fragmentary
- Defined in:
- lib/fragmentary.rb,
lib/fragmentary/config.rb,
lib/fragmentary/widget.rb,
lib/fragmentary/handler.rb,
lib/fragmentary/request.rb,
lib/fragmentary/version.rb,
lib/fragmentary/fragment.rb,
lib/fragmentary/publisher.rb,
lib/fragmentary/subscriber.rb,
lib/fragmentary/session_user.rb,
lib/fragmentary/subscription.rb,
lib/fragmentary/user_session.rb,
lib/fragmentary/request_queue.rb,
lib/fragmentary/widget_parser.rb,
lib/fragmentary/fragments_helper.rb,
lib/fragmentary/jobs/send_requests_job.rb,
lib/fragmentary/jobs/dispatch_handlers_job.rb,
lib/fragmentary/serializers/handler_serializer.rb,
lib/fragmentary/serializers/request_queue_serializer.rb
Defined Under Namespace
Modules: Fragment, FragmentsHelper, Publisher
Classes: Config, DispatchHandlersJob, ExternalUserSession, Handler, HandlerSerializer, InternalUserSession, Request, RequestQueue, RequestQueueSerializer, SendRequestsJob, SessionUser, Subscriber, Subscription, Template, UserWidget, Widget, WidgetParser
Constant Summary
collapse
- VERSION =
"0.4.1"
Class Method Summary
collapse
Class Method Details
.application ⇒ Object
25
26
27
|
# File 'lib/fragmentary.rb', line 25
def self.application
Rails.application
end
|
.application_root_url ⇒ Object
29
30
31
|
# File 'lib/fragmentary.rb', line 29
def self.application_root_url
application.routes.url_helpers.root_url
end
|
.config {|@config| ... } ⇒ Object
Also known as:
setup
18
19
20
21
22
|
# File 'lib/fragmentary.rb', line 18
def self.config
@config ||= Fragmentary::Config.instance
yield @config if block_given?
@config
end
|
.current_user_method ⇒ Object
30
31
32
|
# File 'lib/fragmentary/config.rb', line 30
def self.current_user_method
self.config.current_user_method
end
|
.parse_session_users(session_users = nil) ⇒ Object
Parse a set of session_user options, creating session_users where needed, and return a set of user_type keys. session_users may take several forms:
(1) a hash whose keys are user_type strings and whose values have the form {:credentials => credentials},
where 'credentials' is either a hash of parameters to be submitted when logging in or a proc that
returns those parameters.
(2) an array of hashes as described in (1) above.
(3) an array of user_type strings corresponding to SessionUser objects already defined.
(4) an array containing a mixture of user_type strings and hashes as described in (1) above.
Non-hash elements that don’t represent existing SessionUser objects should raise an exception. Array elements that are hashes should be parsed to create new SessionUser objects. Raise an exception on any attempt to redefine an existing user_type.
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/fragmentary/config.rb', line 45
def self.parse_session_users(session_users = nil)
return nil unless session_users
if session_users.is_a?(Array)
session_users.inject([]) do |acc, v|
if v.is_a?(Hash)
acc + parse_session_users(v)
else
raise "No SessionUser exists for user_type '#{v}'" unless SessionUser.fetch(v)
acc << v
end
end
elsif session_users.is_a?(Hash)
session_users.each_with_object([]) do |(k,v), acc|
acc << k if user = SessionUser.new(k,v)
end
end
end
|