Module: ApiResource
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/api_resource.rb,
lib/api_resource/base.rb,
lib/api_resource/local.rb,
lib/api_resource/mocks.rb,
lib/api_resource/scopes.rb,
lib/api_resource/finders.rb,
lib/api_resource/formats.rb,
lib/api_resource/railtie.rb,
lib/api_resource/version.rb,
lib/api_resource/typecast.rb,
lib/api_resource/callbacks.rb,
lib/api_resource/observing.rb,
lib/api_resource/attributes.rb,
lib/api_resource/conditions.rb,
lib/api_resource/connection.rb,
lib/api_resource/decorators.rb,
lib/api_resource/exceptions.rb,
lib/api_resource/associations.rb,
lib/api_resource/model_errors.rb,
lib/api_resource/custom_methods.rb,
lib/api_resource/log_subscriber.rb,
lib/api_resource/formats/xml_format.rb,
lib/api_resource/formats/json_format.rb,
lib/api_resource/finders/single_finder.rb,
lib/api_resource/association_activation.rb,
lib/api_resource/finders/abstract_finder.rb,
lib/api_resource/finders/resource_finder.rb,
lib/api_resource/conditions/scope_condition.rb,
lib/api_resource/typecasters/date_typecaster.rb,
lib/api_resource/typecasters/time_typecaster.rb,
lib/api_resource/conditions/include_condition.rb,
lib/api_resource/decorators/caching_decorator.rb,
lib/api_resource/typecasters/array_typecaster.rb,
lib/api_resource/typecasters/float_typecaster.rb,
lib/api_resource/conditions/abstract_condition.rb,
lib/api_resource/typecasters/string_typecaster.rb,
lib/api_resource/associations/association_proxy.rb,
lib/api_resource/typecasters/boolean_typecaster.rb,
lib/api_resource/typecasters/integer_typecaster.rb,
lib/api_resource/associations/multi_object_proxy.rb,
lib/api_resource/associations/related_object_hash.rb,
lib/api_resource/associations/single_object_proxy.rb,
lib/api_resource/conditions/association_condition.rb,
lib/api_resource/finders/multi_object_association_finder.rb,
lib/api_resource/associations/has_one_remote_object_proxy.rb,
lib/api_resource/finders/single_object_association_finder.rb,
lib/api_resource/associations/has_many_remote_object_proxy.rb,
lib/api_resource/associations/belongs_to_remote_object_proxy.rb,
lib/api_resource/conditions/multi_object_association_condition.rb,
lib/api_resource/conditions/single_object_association_condition.rb,
lib/api_resource/associations/has_many_through_remote_object_proxy.rb
Defined Under Namespace
Modules: AssociationActivation, Associations, Attributes, Callbacks, Conditions, CustomMethods, Decorators, Finders, Formats, Mocks, ModelErrors, Observing, Scopes, Typecast Classes: BadRequest, Base, ClientError, Connection, ConnectionError, Errors, ForbiddenAccess, Local, LogSubscriber, MethodNotAllowed, NotAcceptable, Observer, Railtie, Redirection, RequestTimeout, ResourceConflict, ResourceGone, ResourceNotFound, SSLError, ServerError, UnauthorizedAccess, UnprocessableEntity
Constant Summary collapse
- DEFAULT_TIMEOUT =
seconds
10- VERSION =
"0.6.12"
Class Method Summary collapse
- .cache(reset = false) ⇒ Object
- .load_mocks_and_factories ⇒ Object
-
.logger ⇒ Object
logger.
-
.open_timeout=(val) ⇒ Object
set the timeout val and reset the connection.
-
.timeout=(val) ⇒ Object
set the timeout val and reset the connection.
-
.with_token(new_token, &block) ⇒ Object
Run a block with a given token - useful for AroundFilters.
- .with_ttl(new_ttl, &block) ⇒ Object
Class Method Details
.cache(reset = false) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/api_resource.rb', line 75 def self.cache(reset = false) @cache = nil if reset @cache ||= begin defined?(Rails) ? Rails.cache : ActiveSupport::Cache::MemoryStore.new rescue ActiveSupport::Cache::MemoryStore.new end end |
.load_mocks_and_factories ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/api_resource.rb', line 52 def self.load_mocks_and_factories require 'hash_dealer' Mocks.clear_endpoints Mocks.init Dir["#{File.dirname(__FILE__)}/../spec/support/requests/*.rb"].each {|f| require f } Dir["#{File.dirname(__FILE__)}/../spec/support/**/*.rb"].each {|f| require f } end |
.logger ⇒ Object
logger
121 122 123 124 125 126 127 |
# File 'lib/api_resource.rb', line 121 def self.logger return @logger if @logger @logger = Log4r::Logger.new("api_resource") @logger.outputters = [Log4r::StdoutOutputter.new('console')] @logger.level = Log4r::INFO @logger end |
.open_timeout=(val) ⇒ Object
set the timeout val and reset the connection
92 93 94 95 96 |
# File 'lib/api_resource.rb', line 92 def self.open_timeout=(val) ApiResource::Base.open_timeout = val self.reset_connection val end |
.timeout=(val) ⇒ Object
set the timeout val and reset the connection
85 86 87 88 89 |
# File 'lib/api_resource.rb', line 85 def self.timeout=(val) ApiResource::Base.timeout = val self.reset_connection val end |
.with_token(new_token, &block) ⇒ Object
Run a block with a given token - useful for AroundFilters
100 101 102 103 104 105 106 107 108 |
# File 'lib/api_resource.rb', line 100 def self.with_token(new_token, &block) old_token = self.token begin self.token = new_token yield ensure self.token = old_token end end |
.with_ttl(new_ttl, &block) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/api_resource.rb', line 110 def self.with_ttl(new_ttl, &block) old_ttl = self.ttl begin self.ttl = new_ttl yield ensure self.ttl = old_ttl end end |