Module: ActivityNotification
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern
- Defined in:
- lib/activity_notification/rails.rb,
app/controllers/activity_notification/apidocs_controller.rb,
app/controllers/activity_notification/notifications_controller.rb,
app/controllers/activity_notification/subscriptions_controller.rb,
app/controllers/activity_notification/notifications_api_controller.rb,
app/controllers/activity_notification/subscriptions_api_controller.rb,
app/controllers/activity_notification/notifications_with_devise_controller.rb,
app/controllers/activity_notification/subscriptions_with_devise_controller.rb,
app/controllers/activity_notification/notifications_api_with_devise_controller.rb,
app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb,
lib/activity_notification.rb,
lib/activity_notification/common.rb,
lib/activity_notification/config.rb,
lib/activity_notification/models.rb,
lib/activity_notification/version.rb,
lib/activity_notification/renderable.rb,
lib/activity_notification/gem_version.rb,
lib/activity_notification/orm/mongoid.rb,
lib/activity_notification/apis/swagger.rb,
lib/activity_notification/orm/dynamoid.rb,
lib/activity_notification/helpers/errors.rb,
lib/activity_notification/mailers/helpers.rb,
lib/activity_notification/orm/active_record.rb,
lib/activity_notification/models/notification.rb,
lib/activity_notification/models/subscription.rb,
lib/activity_notification/roles/acts_as_group.rb,
lib/activity_notification/helpers/view_helpers.rb,
lib/activity_notification/roles/acts_as_common.rb,
lib/activity_notification/roles/acts_as_target.rb,
lib/activity_notification/apis/notification_api.rb,
lib/activity_notification/apis/subscription_api.rb,
lib/activity_notification/models/concerns/group.rb,
lib/activity_notification/optional_targets/base.rb,
lib/activity_notification/models/concerns/target.rb,
lib/activity_notification/optional_targets/slack.rb,
lib/activity_notification/orm/dynamoid/extension.rb,
lib/activity_notification/roles/acts_as_notifier.rb,
lib/activity_notification/models/concerns/notifier.rb,
lib/activity_notification/orm/mongoid/notification.rb,
lib/activity_notification/orm/mongoid/subscription.rb,
lib/activity_notification/roles/acts_as_notifiable.rb,
lib/activity_notification/orm/dynamoid/notification.rb,
lib/activity_notification/orm/dynamoid/subscription.rb,
lib/activity_notification/models/concerns/notifiable.rb,
lib/activity_notification/models/concerns/subscriber.rb,
lib/generators/activity_notification/views_generator.rb,
lib/activity_notification/helpers/polymorphic_helpers.rb,
lib/activity_notification/optional_targets/amazon_sns.rb,
lib/generators/activity_notification/models_generator.rb,
lib/activity_notification/controllers/store_controller.rb,
lib/generators/activity_notification/install_generator.rb,
lib/activity_notification/controllers/common_controller.rb,
lib/activity_notification/orm/active_record/notification.rb,
lib/activity_notification/orm/active_record/subscription.rb,
lib/generators/activity_notification/controllers_generator.rb,
lib/activity_notification/controllers/common_api_controller.rb,
lib/activity_notification/models/concerns/swagger/error_schema.rb,
lib/activity_notification/optional_targets/action_cable_channel.rb,
lib/generators/activity_notification/migration/migration_generator.rb,
lib/activity_notification/optional_targets/action_cable_api_channel.rb,
lib/activity_notification/models/concerns/swagger/notification_schema.rb,
lib/activity_notification/models/concerns/swagger/subscription_schema.rb,
lib/activity_notification/controllers/concerns/swagger/error_responses.rb,
lib/activity_notification/controllers/devise_authentication_controller.rb,
lib/activity_notification/controllers/concerns/swagger/notifications_api.rb,
lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb,
lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb,
lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ActsAsCommon, ActsAsGroup, ActsAsNotifiable, ActsAsNotifier, ActsAsTarget, Association, Common, CommonApiController, CommonController, DeviseAuthenticationController, DynamoidExtension, GEM_VERSION, Generators, Group, Mailers, Models, Notifiable, NotificationApi, Notifier, ORM, OptionalTarget, PolymorphicHelpers, Renderable, StoreController, Subscriber, SubscriptionApi, Swagger, Target, ViewHelpers Classes: ApidocsController, Config, ConfigError, DeleteRestrictionError, Engine, Mailer, NotifiableNotFoundError, Notification, NotificationApiChannel, NotificationApiWithDeviseChannel, NotificationChannel, NotificationWithDeviseChannel, NotificationsApiController, NotificationsApiWithDeviseController, NotificationsController, NotificationsWithDeviseController, NotifyAllJob, NotifyJob, NotifyToJob, RecordInvalidError, Subscription, SubscriptionsApiController, SubscriptionsApiWithDeviseController, SubscriptionsController, SubscriptionsWithDeviseController
Constant Summary collapse
- VERSION =
"2.3.2"
Class Method Summary collapse
-
.cast_to_indifferent_hash(hash = {}) ⇒ HashWithIndifferentAccess
Casts to indifferent hash.
-
.config ⇒ Object
Returns configuration object of ActivityNotification.
-
.configure {|config| ... } ⇒ Object
Sets global configuration options for ActivityNotification.
-
.gem_version ⇒ Object
Returns the version of the currently loaded ActivityNotification as a Gem::Version.
-
.get_controller ⇒ NotificationsController, NotificationsWithDeviseController
Getter for accessing the controller instance.
-
.inherit_orm(model) ⇒ Object
Method used to choose which ORM to load when ActivityNotification::Notification class or ActivityNotification::Subscription class are being autoloaded.
-
.resolve_value(context, thing, *args) ⇒ Object
Used to transform value from metadata to data.
-
.set_controller(controller) ⇒ NotificationsController, NotificationsWithDeviseController
Setter for remembering controller instance.
Class Method Details
.cast_to_indifferent_hash(hash = {}) ⇒ HashWithIndifferentAccess
Casts to indifferent hash
53 54 55 56 57 58 59 |
# File 'lib/activity_notification/common.rb', line 53 def self.cast_to_indifferent_hash(hash = {}) # This is the typical (not-ActionView::TestCase) code path. hash = hash.to_unsafe_h if hash.respond_to?(:to_unsafe_h) # In Rails 5 to_unsafe_h returns a HashWithIndifferentAccess, in Rails 4 it returns Hash hash = hash.with_indifferent_access if hash.instance_of? Hash hash end |
.config ⇒ Object
Returns configuration object of ActivityNotification.
27 28 29 |
# File 'lib/activity_notification.rb', line 27 def self.config @config ||= ActivityNotification::Config.new end |
.configure {|config| ... } ⇒ Object
Sets global configuration options for ActivityNotification. All available options and their defaults are in the example below:
44 45 46 47 |
# File 'lib/activity_notification.rb', line 44 def self.configure yield(config) if block_given? autoload :Association, "activity_notification/orm/#{ActivityNotification.config.orm}" end |
.gem_version ⇒ Object
Returns the version of the currently loaded ActivityNotification as a Gem::Version
3 4 5 |
# File 'lib/activity_notification/gem_version.rb', line 3 def self.gem_version Gem::Version.new VERSION end |
.get_controller ⇒ NotificationsController, NotificationsWithDeviseController
Getter for accessing the controller instance
14 15 16 |
# File 'lib/activity_notification/controllers/store_controller.rb', line 14 def get_controller Thread.current[:activity_notification_controller] end |
.inherit_orm(model) ⇒ Object
Method used to choose which ORM to load when ActivityNotification::Notification class or ActivityNotification::Subscription class are being autoloaded
52 53 54 55 56 |
# File 'lib/activity_notification.rb', line 52 def self.inherit_orm(model) orm = ActivityNotification.config.orm require "activity_notification/orm/#{orm}" "ActivityNotification::ORM::#{orm.to_s.classify}::#{model}".constantize end |
.resolve_value(context, thing, *args) ⇒ Object
Used to transform value from metadata to data. Accepts Symbols, which it will send against context. Accepts Procs, which it will execute with controller and context. Both Symbols and Procs will be passed arguments of this method. Also accepts Hash of these Symbols or Procs. If any other value will be passed, returns original value.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/activity_notification/common.rb', line 14 def self.resolve_value(context, thing, *args) case thing when Symbol symbol_method = context.method(thing) if symbol_method.arity > 1 if args.last.kind_of?(Hash) symbol_method.call(ActivityNotification.get_controller, *args[0...-1], **args[-1]) else symbol_method.call(ActivityNotification.get_controller, *args) end elsif symbol_method.arity > 0 symbol_method.call(ActivityNotification.get_controller) else symbol_method.call end when Proc if thing.arity > 2 thing.call(ActivityNotification.get_controller, context, *args) elsif thing.arity > 1 thing.call(ActivityNotification.get_controller, context) elsif thing.arity > 0 thing.call(context) else thing.call end when Hash thing.dup.tap do |hash| hash.each do |key, value| hash[key] = ActivityNotification.resolve_value(context, value, *args) end end else thing end end |
.set_controller(controller) ⇒ NotificationsController, NotificationsWithDeviseController
Setter for remembering controller instance
7 8 9 |
# File 'lib/activity_notification/controllers/store_controller.rb', line 7 def set_controller(controller) Thread.current[:activity_notification_controller] = controller end |