Module: SimpleFeed
- Defined in:
- lib/simplefeed.rb,
lib/simplefeed/dsl.rb,
lib/simplefeed/feed.rb,
lib/simplefeed/event.rb,
lib/simplefeed/version.rb,
lib/simplefeed/response.rb,
lib/simplefeed/providers.rb,
lib/simplefeed/activity/base.rb,
lib/simplefeed/dsl/formatter.rb,
lib/simplefeed/providers/key.rb,
lib/simplefeed/dsl/activities.rb,
lib/simplefeed/providers/hash.rb,
lib/simplefeed/providers/proxy.rb,
lib/simplefeed/providers/redis.rb,
lib/simplefeed/activity/multi_user.rb,
lib/simplefeed/activity/single_user.rb,
lib/simplefeed/providers/redis/stats.rb,
lib/simplefeed/providers/redis/driver.rb,
lib/simplefeed/providers/base/provider.rb,
lib/simplefeed/providers/redis/provider.rb
Overview
Main namespace module for the SimpleFeed gem. It provides several shortcuts and entry points into the library, such as ability to define and fetch new feeds via define
, and so on.
Defined Under Namespace
Modules: Activity, DSL, Providers Classes: Event, Feed, Response
Constant Summary collapse
- TIME_FORMAT =
'%Y-%m-%d %H:%M:%S.%L'
Class Attribute Summary collapse
-
.registry ⇒ Object
readonly
Returns the value of attribute registry.
Class Method Summary collapse
-
.class_attributes(klass) ⇒ Object
Returns list of class attributes based on the setter methods.
-
.define(name, **options) ⇒ Feed
The feed with the given name, and defined via options and a block.
-
.get(name) ⇒ Feed
The pre-defined feed with the given name.
-
.method_missing(name, *args, **opts, &block) ⇒ Object
Forward all other method calls to the Provider.
-
.provider(provider_name, *args, **opts, &block) ⇒ Provider
A factory method that constructs an instance of a provider based on the provider name and arguments.
-
.symbolize!(hash) ⇒ Object
Shortcut method to symbolize hash keys, using Hashie::Extensions.
Class Attribute Details
.registry ⇒ Object (readonly)
Returns the value of attribute registry.
25 26 27 |
# File 'lib/simplefeed.rb', line 25 def registry @registry end |
Class Method Details
.class_attributes(klass) ⇒ Object
Returns list of class attributes based on the setter methods. Not fool-proof, but works in this context.
70 71 72 |
# File 'lib/simplefeed.rb', line 70 def self.class_attributes(klass) klass.instance_methods.grep(/[^=!]=$/).map { |m| m.to_s.gsub(/=/, '').to_sym } end |
.define(name, **options) ⇒ Feed
Returns the feed with the given name, and defined via options and a block.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/simplefeed.rb', line 31 def define(name, **) name = name.to_sym unless name.is_a?(Symbol) registry[name] ||= Feed.new(name) registry[name].tap do |feed| feed.configure() do yield(feed) if block_given? end end end |
.get(name) ⇒ Feed
Returns the pre-defined feed with the given name.
44 45 46 |
# File 'lib/simplefeed.rb', line 44 def get(name) registry[name.to_sym] end |
.method_missing(name, *args, **opts, &block) ⇒ Object
Forward all other method calls to the Provider
63 64 65 |
# File 'lib/simplefeed.rb', line 63 def method_missing(name, *args, **opts, &block) registry[name] || super end |
.provider(provider_name, *args, **opts, &block) ⇒ Provider
A factory method that constructs an instance of a provider based on the provider name and arguments.
55 56 57 58 59 60 |
# File 'lib/simplefeed.rb', line 55 def provider(provider_name, *args, **opts, &block) provider_class = SimpleFeed::Providers.registry[provider_name] raise ArgumentError, "No provider named #{provider_name} was found, #{SimpleFeed::Providers.registry.inspect}" unless provider_class provider_class.new(*args, **opts, &block) end |
.symbolize!(hash) ⇒ Object
Shortcut method to symbolize hash keys, using Hashie::Extensions
75 76 77 |
# File 'lib/simplefeed.rb', line 75 def self.symbolize!(hash) Hashie::Extensions::SymbolizeKeys.symbolize_keys!(hash) end |