Module: StorageRoom
- Defined in:
- lib/storage_room.rb,
lib/storage_room/array.rb,
lib/storage_room/model.rb,
lib/storage_room/proxy.rb,
lib/storage_room/plugins.rb,
lib/storage_room/version.rb,
lib/storage_room/embedded.rb,
lib/storage_room/resource.rb,
lib/storage_room/accessors.rb,
lib/storage_room/identity_map.rb,
lib/storage_room/models/entry.rb,
lib/storage_room/webhook_call.rb,
lib/storage_room/embeddeds/file.rb,
lib/storage_room/embeddeds/field.rb,
lib/storage_room/embeddeds/image.rb,
lib/storage_room/extensions/symbol.rb,
lib/storage_room/models/collection.rb,
lib/storage_room/embeddeds/location.rb,
lib/storage_room/models/deleted_entry.rb,
lib/storage_room/embeddeds/image_version.rb,
lib/storage_room/extensions/const_defined.rb,
lib/storage_room/embeddeds/webhook_definition.rb,
lib/storage_room/embeddeds/fields/atomic_field.rb,
lib/storage_room/embeddeds/fields/compound_field.rb,
lib/storage_room/embeddeds/fields/association_field.rb,
lib/storage_room/embeddeds/fields/atomic/date_field.rb,
lib/storage_room/embeddeds/fields/atomic/json_field.rb,
lib/storage_room/embeddeds/fields/atomic/time_field.rb,
lib/storage_room/embeddeds/fields/atomic/array_field.rb,
lib/storage_room/embeddeds/fields/atomic/float_field.rb,
lib/storage_room/embeddeds/fields/atomic/string_field.rb,
lib/storage_room/embeddeds/fields/compound/file_field.rb,
lib/storage_room/embeddeds/fields/atomic/boolean_field.rb,
lib/storage_room/embeddeds/fields/atomic/integer_field.rb,
lib/storage_room/embeddeds/fields/compound/image_field.rb,
lib/storage_room/embeddeds/fields/compound/location_field.rb,
lib/storage_room/embeddeds/fields/compound/attachment_field.rb,
lib/storage_room/embeddeds/fields/associations/one_association_field.rb,
lib/storage_room/embeddeds/fields/associations/many_association_field.rb
Defined Under Namespace
Modules: Accessors, Extensions, IdentityMap, Plugins Classes: AbstractMethodError, Array, ArrayField, AssociationField, AtomicField, AttachmentField, BooleanField, ClassNotFoundError, Collection, CompoundField, DateField, DeletedEntry, Embedded, Entry, Field, File, FileField, FloatField, Image, ImageField, ImageVersion, IntegerField, JsonField, Location, LocationField, ManyAssociationField, Model, OneAssociationField, OptimisticLockingError, Proxy, RequestFailedError, Resource, ResourceNotLoadedError, StringField, TimeField, WebhookCall, WebhookDefinition
Constant Summary collapse
- VERSION =
'0.3.24'
Class Attribute Summary collapse
-
.account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
.api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
.debug ⇒ Object
Returns the value of attribute debug.
-
.proxy_port ⇒ Object
readonly
Returns the value of attribute proxy_port.
-
.proxy_server ⇒ Object
readonly
Returns the value of attribute proxy_server.
-
.ssl ⇒ Object
Returns the value of attribute ssl.
-
.timeout ⇒ Object
:nodoc:.
-
.user_agent ⇒ Object
Returns the value of attribute user_agent.
Class Method Summary collapse
-
.add_entry_class_mapping(name, class_name) ⇒ Object
Add a new mapping.
-
.authenticate(account_id, api_key) ⇒ Object
Authenticate once before making any requests with your account id and the application’s api key.
-
.class_for_name(name) ⇒ Object
Return a Ruby class for a StorageRoom type.
-
.entry_class_for_name(name) ⇒ Object
:nodoc:.
-
.entry_class_mappings ⇒ Object
Hash of all mappings from an Entry’s @type to a local Ruby class, if a mapping doesn’t exist a class name will be created automatically.
-
.http_proxy(server, port) ⇒ Object
Set an HTTP proxy server.
-
.log(msg) ⇒ Object
:nodoc:.
-
.request_options ⇒ Object
Return the request options used by HTTParty.
-
.server ⇒ Object
:nodoc:.
-
.server=(server) ⇒ Object
Change the server to connect to.
- .version ⇒ Object
Class Attribute Details
.account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
71 72 73 |
# File 'lib/storage_room.rb', line 71 def account_id @account_id end |
.api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
71 72 73 |
# File 'lib/storage_room.rb', line 71 def api_key @api_key end |
.debug ⇒ Object
Returns the value of attribute debug.
72 73 74 |
# File 'lib/storage_room.rb', line 72 def debug @debug end |
.proxy_port ⇒ Object (readonly)
Returns the value of attribute proxy_port.
71 72 73 |
# File 'lib/storage_room.rb', line 71 def proxy_port @proxy_port end |
.proxy_server ⇒ Object (readonly)
Returns the value of attribute proxy_server.
71 72 73 |
# File 'lib/storage_room.rb', line 71 def proxy_server @proxy_server end |
.ssl ⇒ Object
Returns the value of attribute ssl.
71 72 73 |
# File 'lib/storage_room.rb', line 71 def ssl @ssl end |
.timeout ⇒ Object
:nodoc:
103 104 105 |
# File 'lib/storage_room.rb', line 103 def timeout @timeout end |
.user_agent ⇒ Object
Returns the value of attribute user_agent.
71 72 73 |
# File 'lib/storage_room.rb', line 71 def user_agent @user_agent end |
Class Method Details
.add_entry_class_mapping(name, class_name) ⇒ Object
Add a new mapping
120 121 122 |
# File 'lib/storage_room.rb', line 120 def add_entry_class_mapping(name, class_name) self.entry_class_mappings[name] = class_name.to_s end |
.authenticate(account_id, api_key) ⇒ Object
Authenticate once before making any requests with your account id and the application’s api key
75 76 77 78 79 80 |
# File 'lib/storage_room.rb', line 75 def authenticate(account_id, api_key) Resource.basic_auth(api_key, 'X') @api_key = api_key @account_id = account_id update_uri end |
.class_for_name(name) ⇒ Object
Return a Ruby class for a StorageRoom type
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/storage_room.rb', line 146 def class_for_name(name) name_with_mapping = entry_class_for_name(name) begin if StorageRoom.is_constant_defined?(name_with_mapping) return "StorageRoom::#{name_with_mapping}".constantize end rescue NameError # could contain spaces etc. end begin return name_with_mapping.constantize rescue NameError raise ClassNotFoundError.new("Unknown class: #{name}") end end |
.entry_class_for_name(name) ⇒ Object
:nodoc:
124 125 126 |
# File 'lib/storage_room.rb', line 124 def entry_class_for_name(name) #:nodoc: self.entry_class_mappings[name] || name end |
.entry_class_mappings ⇒ Object
Hash of all mappings from an Entry’s @type to a local Ruby class, if a mapping doesn’t exist a class name will be created automatically
115 116 117 |
# File 'lib/storage_room.rb', line 115 def entry_class_mappings @entry_class_mappings ||= {} end |
.http_proxy(server, port) ⇒ Object
Set an HTTP proxy server
139 140 141 142 143 |
# File 'lib/storage_room.rb', line 139 def http_proxy(server, port) @proxy_server = server @proxy_port = port Resource.http_proxy(server, port) end |
.log(msg) ⇒ Object
:nodoc:
163 164 165 |
# File 'lib/storage_room.rb', line 163 def log(msg) #:nodoc: puts("[DEBUG] #{msg}") if debug end |
.request_options ⇒ Object
Return the request options used by HTTParty
108 109 110 111 112 |
# File 'lib/storage_room.rb', line 108 def { :timeout => timeout } end |
.server ⇒ Object
:nodoc:
94 95 96 |
# File 'lib/storage_room.rb', line 94 def server #:nodoc: @server || 'api.storageroomapp.com' end |
.server=(server) ⇒ Object
Change the server to connect to. This should only be relevant for developers of the library.
89 90 91 92 |
# File 'lib/storage_room.rb', line 89 def server=(server) #:nodoc: @server = server update_uri end |
.version ⇒ Object
128 129 130 |
# File 'lib/storage_room.rb', line 128 def version StorageRoom::VERSION end |