Class: RemoteEntity::EntityResource

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/remote_entity/entity_resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ EntityResource

Returns a new instance of EntityResource.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/remote_entity/entity_resource.rb', line 6

def initialize(attrs = {})      
  @@schema ||= []
  
  attrs = HashWithIndifferentAccess.new(attrs)
  @@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



24
25
26
# File 'lib/remote_entity/entity_resource.rb', line 24

def self.schema(*args)
  @@schema = args
end

.serviceObject



44
45
46
# File 'lib/remote_entity/entity_resource.rb', line 44

def self.service
  return defined?(@@service) ? @@service : nil
end

.service=(service) ⇒ Object

Helps us set the site automatically



39
40
41
42
# File 'lib/remote_entity/entity_resource.rb', line 39

def self.service=(service)
  @@service = service
  self.update_site
end

.versionObject



34
35
36
# File 'lib/remote_entity/entity_resource.rb', line 34

def self.version
  return defined?(@@api_version) ? @@api_version : nil
end

.version=(version) ⇒ Object

Helps us set the site automatically.



29
30
31
32
# File 'lib/remote_entity/entity_resource.rb', line 29

def self.version=(version)
  @@api_version = version
  self.update_site
end