Skip to content

Commit

Permalink
Extract resolve_definition into a private method
Browse files Browse the repository at this point in the history
  • Loading branch information
smdern committed Dec 6, 2018
1 parent ff63ad0 commit ff5382a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/scenic/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,8 @@ def to_sql
end
end

definition = views_paths.flat_map do |directory|
Dir.glob("#{directory}/**/#{filename}")
end.first

unless definition
raise "Unable to locate #{filename} in #{views_paths}"
end

definition
def definition_path
resolve_definition || raise("Unable to locate #{filename} in #{views_paths}")
end

def full_path
Expand All @@ -40,6 +32,12 @@ def version

private

def resolve_definition
views_paths.flat_map do |directory|
Dir.glob("#{directory}/**/#{filename}")
end.first
end

def views_paths
Rails.application.config.paths["db/views"].expanded
end
Expand Down

0 comments on commit ff5382a

Please sign in to comment.