Class: RemoteEntity::EntityResource
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- RemoteEntity::EntityResource
- Defined in:
- lib/remote_entity/entity_resource.rb
Class Method Summary collapse
-
.schema(*args) ⇒ Object
Defines methods for the following properties on every instance of this type that is created.
- .service ⇒ Object
-
.service=(service) ⇒ Object
Helps us set the site automatically.
- .site ⇒ Object
- .version ⇒ Object
-
.version=(version) ⇒ Object
Helps us set the site automatically.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ EntityResource
constructor
A new instance of EntityResource.
Constructor Details
#initialize(attrs = {}) ⇒ EntityResource
Returns a new instance of EntityResource.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/remote_entity/entity_resource.rb', line 6 def initialize(attrs = {}) attrs = HashWithIndifferentAccess.new(attrs) self.class.get_schema.each do |attribute| if !attrs.has_key?(attribute) attrs[attribute] = nil end end if !attrs.has_key?(:remote_entity_id) attrs[:remote_entity_id] = nil end super(attrs) end |
Class Method Details
.schema(*args) ⇒ Object
Defines methods for the following properties on every instance of this type that is created
22 23 24 |
# File 'lib/remote_entity/entity_resource.rb', line 22 def self.schema(*args) @schema = args end |
.service ⇒ Object
42 43 44 |
# File 'lib/remote_entity/entity_resource.rb', line 42 def self.service return defined?(@service) ? @service : nil end |
.service=(service) ⇒ Object
Helps us set the site automatically
37 38 39 40 |
# File 'lib/remote_entity/entity_resource.rb', line 37 def self.service=(service) @service = service self.update_site end |
.site ⇒ Object
46 47 48 49 |
# File 'lib/remote_entity/entity_resource.rb', line 46 def self.site self.update_site super end |
.version ⇒ Object
32 33 34 |
# File 'lib/remote_entity/entity_resource.rb', line 32 def self.version return defined?(@api_version) ? @api_version : nil end |
.version=(version) ⇒ Object
Helps us set the site automatically.
27 28 29 30 |
# File 'lib/remote_entity/entity_resource.rb', line 27 def self.version=(version) @api_version = version self.update_site end |