Class: TelestreamCloud::Resource
- Extended by:
- FactoryConnection
- Includes:
- Associations, Destroyers, FactoryConnection
- Defined in:
- lib/telestream_cloud/resources/resource.rb
Constant Summary
Constants included from Router
TelestreamCloud::Router::VAR_PATTERN
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .factory ⇒ Object
-
.method_missing(method_symbol, *args, &block) ⇒ Object
delegate to the scope if the method exists.
Instance Method Summary collapse
- #factory ⇒ Object
-
#initialize(attributes = {}) ⇒ Resource
constructor
A new instance of Resource.
- #reload ⇒ Object
Methods included from FactoryConnection
Methods included from Associations
Methods included from Destroyers
Methods inherited from Base
#changed?, #id, #id=, #inspect, #new?, sti_name, #to_json
Methods included from Finders
Methods included from Builders
Methods included from Router
included, #replace_pattern_with_self_variables
Constructor Details
#initialize(attributes = {}) ⇒ Resource
Returns a new instance of Resource.
7 8 9 10 |
# File 'lib/telestream_cloud/resources/resource.rb', line 7 def initialize(attributes={}) super(attributes) @attributes['factory_id'] ||= TelestreamCloud.factory.id end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class TelestreamCloud::Base
Class Method Details
.factory ⇒ Object
15 16 17 |
# File 'lib/telestream_cloud/resources/resource.rb', line 15 def factory TelestreamCloud.factory end |
.method_missing(method_symbol, *args, &block) ⇒ Object
delegate to the scope if the method exists
20 21 22 23 24 25 26 27 |
# File 'lib/telestream_cloud/resources/resource.rb', line 20 def method_missing(method_symbol, *args, &block) scope = TelestreamCloud::const_get("#{sti_name}Scope").new(self) if scope.respond_to?(method_symbol) scope.send(method_symbol, *args, &block) else super end end |
Instance Method Details
#factory ⇒ Object
31 32 33 |
# File 'lib/telestream_cloud/resources/resource.rb', line 31 def factory TelestreamCloud.factories[factory_id] end |
#reload ⇒ Object
35 36 37 38 39 |
# File 'lib/telestream_cloud/resources/resource.rb', line 35 def reload perform_reload("factory_id" => factory_id) reset_associations self end |