Module: Fog::Service
- Included in:
- AWS::EC2, AWS::ELB, AWS::S3, AWS::SimpleDB, Bluebox, Linode, Local, NewServers, Rackspace::Files, Rackspace::Servers, Slicehost, Vcloud, Vcloud::Extension
- Defined in:
- lib/fog/service.rb
Class Method Summary collapse
Instance Method Summary collapse
- #model(new_model) ⇒ Object
- #model_path(new_path) ⇒ Object
- #models ⇒ Object
- #request(new_request) ⇒ Object
- #request_path(new_path) ⇒ Object
- #requests ⇒ Object
- #requirements ⇒ Object
- #requires(*args) ⇒ Object
- #reset_data(keys = Mock.data.keys) ⇒ Object
Class Method Details
.extended(other) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fog/service.rb', line 4 def self.extended(other) super other.module_eval <<-EOS, __FILE__, __LINE__ class Error < Fog::Errors::Error; end class NotFound < Fog::Errors::NotFound; end module Collections; end def self.new(options={}) missing = [] for requirement in requirements missing << requirement unless options[requirement] end unless missing.empty? if missing.length == 1 raise(ArgumentError, [missing.first, "is required for this service"].join(' ')) else raise(ArgumentError, [missing[0...-1].join(", "), 'and', missing[-1], 'are required for this service'].join(' ')) end end unless @required for model in models require [@model_path, model].join('/') end for request in requests require [@request_path, request].join('/') end @required = true end instance = if Fog.mocking? Mock.new(options) else Real.new(options) end if self.respond_to?(:after_new) instance = self.after_new(instance, options) end instance end EOS end |
Instance Method Details
#model(new_model) ⇒ Object
53 54 55 |
# File 'lib/fog/service.rb', line 53 def model(new_model) models << new_model end |
#model_path(new_path) ⇒ Object
49 50 51 |
# File 'lib/fog/service.rb', line 49 def model_path(new_path) @model_path = new_path end |
#models ⇒ Object
57 58 59 |
# File 'lib/fog/service.rb', line 57 def models @models ||= [] end |
#request(new_request) ⇒ Object
65 66 67 |
# File 'lib/fog/service.rb', line 65 def request(new_request) requests << new_request end |
#request_path(new_path) ⇒ Object
61 62 63 |
# File 'lib/fog/service.rb', line 61 def request_path(new_path) @request_path = new_path end |
#requests ⇒ Object
69 70 71 |
# File 'lib/fog/service.rb', line 69 def requests @requests ||= [] end |
#requirements ⇒ Object
77 78 79 |
# File 'lib/fog/service.rb', line 77 def requirements @requirements ||= [] end |
#requires(*args) ⇒ Object
73 74 75 |
# File 'lib/fog/service.rb', line 73 def requires(*args) requirements.concat(args) end |
#reset_data(keys = Mock.data.keys) ⇒ Object
81 82 83 |
# File 'lib/fog/service.rb', line 81 def reset_data(keys=Mock.data.keys) Mock.reset_data(keys) end |