i want have 1 main class , inside variables want call inside other classes. example:
class awss3initalization attr_reader :resource, :client def initialize resource, client @resource = resource @client = client # define variables below? think not right place put them @resource = aws::s3::resource.new(region: 'region', access_key_id: 'my-key', secret_access_key: 'secret-key') @client = aws::s3::client.new(region: 'region', access_key_id: 'my-key', secret_access_key: 'secret-key') end end
i want able call @resource , @client in other classes have. best way this?
best way inherit other classes awss3initalization
like:
class foo < awss3initalization end class bar < awss3initalization end
then able access variables parent class subclasses.
update
class awss3initialization access_key = <read-from-yml> secret_key = <read-from-yml> def self.resource aws::s3::resource.new(...) end def self.client aws::s3::client.new(...) end end
Comments
Post a Comment