Class: Smash::CloudPowers::Resource

Inherits:
Object
  • Object
show all
Includes:
AwsResources, Creatable, Helpers, Zenv
Defined in:
lib/cloud_powers/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Zenv

#env_vars, #i_vars, #lsof_cwd, #pid, #proc_cwd, #process_search, #project_root, #project_root=, #ps_cwd, #system_vars, #zfind, #zselect

Methods included from Helpers

#create_logger, #log_file, #logger

Methods included from PathHelp

#common_delimiter, #expand_path, #file_exists?, #file_search, #filename?, #job_exist?, #job_path, #job_require_path, #path_search, #paths_gcd, #paths_lcd, #to_path, #to_pathname, #to_realpath, #touch, #zlib_path

Methods included from LogicHelp

#attr_map, #called_from, #i_var_hash, #instance_attr_accessor, #smart_retry, #update_message_body, #wait_until

Methods included from LangHelp

#deep_modify_keys_with, #extract!, #find_and_remove, #format_error_message, #from_json, #modify_keys_with, #to_basic_hash, #to_camel, #to_hyph, #to_i_var, #to_pascal, #to_ruby_file_name, #to_snake, #valid_json?, #valid_url?

Methods included from AwsResources

#ec2, #image, #kinesis, #queue_poller, #region, #s3, #sns, #sqs

Methods included from Auth

creds, region

Methods included from Creatable

included

Constructor Details

#initialize(name:, **config) ⇒ Resource

Usually this method is called by calling super in another class that inherits from this class. The initialize method follows the method signature for the active record-like pattern being followed throughout the code



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cloud_powers/resource.rb', line 35

def initialize(name:, **config)
  @project_root = config[:project_root]
  @linked = false
  @saved = false
  @client = config[:client]
  @type = to_snake(config[:named_type] || config[:type] || self.class.name.split('::').last)
  @call_name = to_snake("#{name}_#{@type}")
  @name = name
  @meta = Array.new # TODO: create a Meta resource and use it here
  @tags = @meta
  logger.debug '@tags will be deprecated in V2.  Please use @meta'
end

Instance Attribute Details

#call_nameObject

the name this resource can be set and retrieved by



17
18
19
# File 'lib/cloud_powers/resource.rb', line 17

def call_name
  @call_name
end

#clientObject

client used to make HTTP requests to the cloud



15
16
17
# File 'lib/cloud_powers/resource.rb', line 15

def client
  @client
end

#linkedObject

whether or not a call has been made to the cloud to back this resource



21
22
23
# File 'lib/cloud_powers/resource.rb', line 21

def linked
  @linked
end

#metaObject

metadata, i.e. tracking on the remote resource that maps to this resource



23
24
25
# File 'lib/cloud_powers/resource.rb', line 23

def meta
  @meta
end

#nameObject

the given name for this resource



19
20
21
# File 'lib/cloud_powers/resource.rb', line 19

def name
  @name
end

#remote_idObject

the ID in the cloud; e.g. ARN for AWS, etc



25
26
27
# File 'lib/cloud_powers/resource.rb', line 25

def remote_id
  @remote_id
end

#tagsObject

Returns the value of attribute tags.



27
28
29
# File 'lib/cloud_powers/resource.rb', line 27

def tags
  @tags
end

#typeObject

the type of resource this was instantiated as



29
30
31
# File 'lib/cloud_powers/resource.rb', line 29

def type
  @type
end