Module: ActiveStorageSaas::StorageServiceConfigurationMixin::InstanceMethods

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_storage_saas/storage_service_configuration_model_mixin.rb

Instance Method Summary collapse

Instance Method Details

#to_serviceObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_storage_saas/storage_service_configuration_model_mixin.rb', line 30

def to_service
  defined_service = ActiveStorage::Blob.services.fetch(service_name)
  klass = defined_service.class
  options = ActiveStorage::Blob.services.send(:configurations).fetch(service_name.to_sym)
  options.deep_merge! service_options.deep_symbolize_keys
  klass.new(**options).tap do |instance|
    instance.instance_eval <<~RUBY
      define_singleton_method(:name) { "#{to_service_name}" }
    RUBY
  end
end

#to_service_nameObject



42
43
44
# File 'lib/active_storage_saas/storage_service_configuration_model_mixin.rb', line 42

def to_service_name
  "#{self.class.name}:#{id}"
end