module MSS::Core::Model

@api private

Attributes

config[R]

@return [Configuration] Returns the configuration for this object.

Public Class Methods

new(*args) click to toggle source

@api private

# File lib/mss/core/model.rb, line 20
def initialize(*args)
  options = args.last.kind_of?(Hash) ? args.last : {}
  @config = case
  when options[:config] then options[:config]
  when args.first.respond_to?(:config) then args.first.config
  else MSS.config
  end
end

Public Instance Methods

client() click to toggle source

Each class including this module has its own client class. Generally it is the service namespace suffixed by client:

  • s3_client

  • simple_db_client

@return Retruns the proper client class for the given model.

# File lib/mss/core/model.rb, line 39
def client
  @config.send("#{config_prefix}_client")
end
config_prefix() click to toggle source

@return [String] The short name of the service as used in coniguration.

(e.g. SimpleDB::Client.config_prefix #=> 'simple_db')
# File lib/mss/core/model.rb, line 45
def config_prefix
  Inflection.ruby_name(self.class.to_s.split(/::/)[1])
end
inspect() click to toggle source

@return [String] A sensible default inspect string.

# File lib/mss/core/model.rb, line 50
def inspect
  "<#{self.class}>"
end
to_yaml_properties() click to toggle source

@api private

# File lib/mss/core/model.rb, line 55
def to_yaml_properties
  instance_variables.map(&:to_s) - %w(@config)
end