Sha256: 824526c766639f53d7a29f1ee7d205be763b8f004279f0e0f4dbd0d98b71f79b
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
require 'app_store/client' require 'app_store/application' require 'app_store/helpers/string' require 'app_store/helpers/proxy' # Define an agent which is linked to a specific store front and can perform all calls to this specific store. # Accepts every AppStore class as a method, ex : # = Examples # agent = AppStore::Agent.new(:store_front => :fr) # agent.category.featured # => will call Category.featured with store front set to :fr # agent.application.find_by_id(42) # => will call Application.find_by_id(42) with store front set to :fr # agent.application.find_by_id(42, :bleh => 'yeah') # => also accepts extra arguments and merge them with store front class AppStore::Agent def initialize(args = {}) @store_front = AppStore::Client::StoreFronts[args[:store_front]] || AppStore::Client::DefaultStoreFront @client = AppStore::Client.new(:store_front => @store_front) end private def method_missing(method, *args) # OPTIMIZE: we should use a 'camelize' method instead of capitalize AppStore::Helper::Proxy.new :to => "AppStore::#{method.to_s.capitalize}".constantize, :extra => {:client => @client} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
app_store-0.1.2 | lib/app_store/agent.rb |
app_store-0.1.0 | lib/app_store/agent.rb |