Module: SharkApps

Defined in:
lib/sharkapps.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods, ViewHelpers Classes: NotConfigured

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.app_idObject

Returns the value of attribute app_id.



4
5
6
# File 'lib/sharkapps.rb', line 4

def app_id
  @app_id
end

.canvas_nameObject

Returns the value of attribute canvas_name.



4
5
6
# File 'lib/sharkapps.rb', line 4

def canvas_name
  @canvas_name
end

.debug_modeObject

Returns the value of attribute debug_mode.



4
5
6
# File 'lib/sharkapps.rb', line 4

def debug_mode
  @debug_mode
end

.passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/sharkapps.rb', line 4

def password
  @password
end

.server_urlObject

Returns the value of attribute server_url.



4
5
6
# File 'lib/sharkapps.rb', line 4

def server_url
  @server_url
end

.usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/sharkapps.rb', line 4

def username
  @username
end

Class Method Details

.configuration=(hash) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/sharkapps.rb', line 41

def self.configuration=(hash)
  self.server_url = hash[:server_url]
  self.username = hash[:username]
  self.password = hash[:password]
  self.app_id = hash[:app_id]
  self.canvas_name = hash[:canvas_name]
  self.debug_mode = hash[:debug_mode]
end

.included(base) ⇒ Object



61
62
63
# File 'lib/sharkapps.rb', line 61

def self.included(base)
  base.extend(ClassMethods)
end

.load_sharkapps_yamlObject

Raises:



50
51
52
53
54
55
56
# File 'lib/sharkapps.rb', line 50

def self.load_sharkapps_yaml
  config = YAML.load(ERB.new(File.read(File.join(::Rails.root,"config","sharkapps.yml"))).result)[::Rails.env]
  raise NotConfigured.new("Unable to load configuration for #{::Rails.env} from sharkapps.yml. Is it set up?") if config.nil?
  self.configuration = config.with_indifferent_access
  Subscription.initialize_from_yaml
  AppformaAccount.initialize_from_yaml
end

.raise_unconfigured_exceptionObject

Raises:



37
38
39
# File 'lib/sharkapps.rb', line 37

def self.raise_unconfigured_exception
  raise NotConfigured.new("No configuration provided for Shark Apps. Call SharkApps.load_sharkapps_yaml in an initializer")
end