Skip to content

Commit 39ef65f

Browse files
authored
Merge branch 'master' into ruby-head
2 parents 0af5723 + 9b98b65 commit 39ef65f

File tree

8 files changed

+21
-17
lines changed

8 files changed

+21
-17
lines changed

lib/fx.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def self.load
2828

2929
# @return [Fx::Configuration] F(x)'s current configuration
3030
def self.configuration
31-
@_configuration ||= Configuration.new
31+
@_configuration ||= Fx::Configuration.new
3232
end
3333

3434
# Set F(x)'s configuration

lib/fx/adapters/postgres.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def initialize(connectable = ActiveRecord::Base)
4747
#
4848
# @return [Array<Fx::Function>]
4949
def functions
50-
Functions.all(connection)
50+
Fx::Adapters::Postgres::Functions.all(connection)
5151
end
5252

5353
# Returns an array of triggers in the database.
@@ -57,7 +57,7 @@ def functions
5757
#
5858
# @return [Array<Fx::Trigger>]
5959
def triggers
60-
Triggers.all(connection)
60+
Fx::Adapters::Postgres::Triggers.all(connection)
6161
end
6262

6363
# Creates a function in the database.
@@ -152,7 +152,7 @@ def drop_trigger(name, on:)
152152
delegate :execute, to: :connection
153153

154154
def connection
155-
Connection.new(connectable.connection)
155+
Fx::Adapters::Postgres::Connection.new(connectable.connection)
156156
end
157157
end
158158
end

lib/fx/adapters/postgres/functions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Functions
3030
#
3131
# @return [Array<Fx::Function>]
3232
def self.all(connection)
33-
QueryExecutor.call(
33+
Fx::Adapters::Postgres::QueryExecutor.call(
3434
connection: connection,
3535
query: FUNCTIONS_WITH_DEFINITIONS_QUERY,
3636
model_class: Fx::Function

lib/fx/adapters/postgres/triggers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Triggers
3030
#
3131
# @return [Array<Fx::Trigger>]
3232
def self.all(connection)
33-
QueryExecutor.call(
33+
Fx::Adapters::Postgres::QueryExecutor.call(
3434
connection: connection,
3535
query: TRIGGERS_WITH_DEFINITIONS_QUERY,
3636
model_class: Fx::Trigger

lib/fx/command_recorder.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def initialize(args)
6868
end
6969

7070
def function
71-
@args[0]
71+
args[0]
7272
end
7373

7474
def version
@@ -84,13 +84,15 @@ def invert_version
8484
end
8585

8686
def to_a
87-
@args.to_a
87+
args.to_a
8888
end
8989

9090
private
9191

92+
attr_reader :args
93+
9294
def options
93-
@options ||= @args[1] || {}
95+
@options ||= args[1] || {}
9496
end
9597

9698
def options_for_revert

lib/fx/definition.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ def self.trigger(name:, version:)
1414

1515
def initialize(name:, version:, type:)
1616
@name = name
17-
@version = version.to_i
17+
@version_number = version.to_i
1818
@type = type
1919
end
2020

2121
def to_sql
2222
content = File.read(find_file || full_path)
23-
raise "Define #{@type} in #{path} before migrating." if content.empty?
23+
raise "Define #{type} in #{path} before migrating." if content.empty?
2424

2525
content
2626
end
@@ -30,17 +30,19 @@ def full_path
3030
end
3131

3232
def path
33-
@_path ||= File.join("db", @type.pluralize, filename)
33+
@_path ||= File.join("db", type.pluralize, filename)
3434
end
3535

3636
def version
37-
@version.to_s.rjust(2, "0")
37+
version_number.to_s.rjust(2, "0")
3838
end
3939

4040
private
4141

42+
attr_reader :name, :version_number, :type
43+
4244
def filename
43-
@_filename ||= "#{@name}_v#{version}.sql"
45+
@_filename ||= "#{name}_v#{version}.sql"
4446
end
4547

4648
def find_file

lib/generators/fx/function/function_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def migration_class_name
7272
end
7373

7474
def formatted_name
75-
NameHelper.format_for_migration(singular_name)
75+
Fx::Generators::NameHelper.format_for_migration(singular_name)
7676
end
7777
end
7878

lib/generators/fx/trigger/trigger_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ def migration_class_name
6666
end
6767

6868
def formatted_name
69-
NameHelper.format_for_migration(singular_name)
69+
Fx::Generators::NameHelper.format_for_migration(singular_name)
7070
end
7171

7272
def formatted_table_name
73-
NameHelper.format_table_name_from_hash(table_name)
73+
Fx::Generators::NameHelper.format_table_name_from_hash(table_name)
7474
end
7575
end
7676

0 commit comments

Comments
 (0)