Class: TalkToYourApp::ConnectionRegistry::ConnectionSpec

Inherits:
Struct
  • Object
show all
Defined in:
lib/talk_to_your_app/connection_registry.rb

Overview

One declared connection. ‘database` is a database.yml config key; `role` is :reading or :writing. A :reading connection prevents writes at the Rails layer (defense in depth on top of a genuinely read-only DB role).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#databaseObject

Returns the value of attribute database

Returns:

  • (Object)

    the current value of database



18
19
20
# File 'lib/talk_to_your_app/connection_registry.rb', line 18

def database
  @database
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



18
19
20
# File 'lib/talk_to_your_app/connection_registry.rb', line 18

def name
  @name
end

#replicaObject

Returns the value of attribute replica

Returns:

  • (Object)

    the current value of replica



18
19
20
# File 'lib/talk_to_your_app/connection_registry.rb', line 18

def replica
  @replica
end

#roleObject

Returns the value of attribute role

Returns:

  • (Object)

    the current value of role



18
19
20
# File 'lib/talk_to_your_app/connection_registry.rb', line 18

def role
  @role
end

#statement_timeoutObject

Returns the value of attribute statement_timeout

Returns:

  • (Object)

    the current value of statement_timeout



18
19
20
# File 'lib/talk_to_your_app/connection_registry.rb', line 18

def statement_timeout
  @statement_timeout
end

Instance Method Details

#prevent_writes?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/talk_to_your_app/connection_registry.rb', line 23

def prevent_writes?
  reading?
end

#reading?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/talk_to_your_app/connection_registry.rb', line 19

def reading?
  role == :reading
end