Module: RailsAssist::Artifact::View::FileName

Included in:
CRUD::Delete::ViewHelper, RailsAssist::Artifact::View, RailsAssist::Artifact::View
Defined in:
lib/rails_artifactor/artifact/file_name/view.rb

Defined Under Namespace

Modules: Helper

Constant Summary collapse

DIR =
RailsAssist::Artifact::Directory

Instance Method Summary collapse

Instance Method Details

#get_view_args(*args) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
51
52
53
# File 'lib/rails_artifactor/artifact/file_name/view.rb', line 44

def get_view_args *args
  args = args.flatten
  raise ArgumentError, "view_file_name must be called with one or more arguments to return a view file" if args.size == 0
  case args.size
  when 1
    SingleArg.get_view_args *args
  else
    TwoArgs.get_view_args *args
  end
end

#view_file_name(*args) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/rails_artifactor/artifact/file_name/view.rb', line 35

def view_file_name *args
  folder, action, type = get_view_args(args)
  options = last_option args
  root_path = options[:root_path]
  views_path = options[:views_path]
  views_path ||= File.join(root_path, 'app/views') if root_path
  File.expand_path File.join(views_path || DIR.view_dirpath, folder.to_s, "#{action}.#{type}")
end