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/key/type.rb,
lib/simplefeed/response.rb,
lib/simplefeed/providers.rb,
lib/simplefeed/key/template.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/redis.rb,
lib/simplefeed/providers/proxy.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/hash/provider.rb,
lib/simplefeed/providers/base/provider.rb,
lib/simplefeed/providers/hash/paginator.rb,
lib/simplefeed/providers/redis/provider.rb

Defined Under Namespace

Modules: Activity, DSL, Key, Providers Classes: Event, Feed, Response

Constant Summary collapse

VERSION =
'1.1.1'

Class Method Summary collapse

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.



46
47
48
# File 'lib/simplefeed.rb', line 46

def self.class_attributes(klass)
  klass.instance_methods.grep(%r{[^=!]=$}).map { |m| m.to_s.gsub(/=/, '').to_sym }
end

.define(name, **options, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/simplefeed.rb', line 17

def self.define(name, **options, &block)
  name = name.to_sym unless name.is_a?(Symbol)
  feed = registry[name] ? registry[name] : SimpleFeed::Feed.new(name)
  feed.configure(options) do
    block.call(feed) if block
  end
  registry[name] = feed
  feed
end

.get(name) ⇒ Object



27
28
29
# File 'lib/simplefeed.rb', line 27

def self.get(name)
  registry[name.to_sym]
end

.method_missing(name, *args, &block) ⇒ Object

Forward all other method calls to Provider



39
40
41
# File 'lib/simplefeed.rb', line 39

def method_missing(name, *args, &block)
  registry[name] || super
end

.provider(provider_name, *args, **opts, &block) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
# File 'lib/simplefeed.rb', line 31

def self.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

.registryObject



13
14
15
# File 'lib/simplefeed.rb', line 13

def self.registry
  @registry
end

.symbolize!(hash) ⇒ Object



50
51
52
# File 'lib/simplefeed.rb', line 50

def self.symbolize!(hash)
  Hashie::Extensions::SymbolizeKeys.symbolize_keys!(hash)
end