Permalink
Browse files

Better syntax highlighting in crudify

  • Loading branch information...
bricesanchez authored and parndt committed Sep 10, 2018
1 parent 0dec51a commit 698554dc6954129920c717ccd6c80cfe0eedd15f
Showing with 14 additions and 15 deletions.
  1. +14 −15 core/lib/refinery/crud.rb
View
@@ -53,7 +53,7 @@ def crudify(model_name, options = {})
singular_name = options[:singular_name]
plural_name = options[:plural_name]
module_eval %(
module_eval <<-RUBY, __FILE__, __LINE__ + 1
def self.crudify_options
#{options.inspect}
end
@@ -227,21 +227,21 @@ def #{singular_name}_params
:create_or_update_successful,
:create_or_update_unsuccessful,
:merge_position_into_params!
), __FILE__, __LINE__
RUBY
# Methods that are only included when this controller is searchable.
if options[:searchable]
if options[:paging]
module_eval %(
module_eval <<-RUBY, __FILE__, __LINE__ + 1
def index
search_all_#{plural_name} if searching?
paginate_all_#{plural_name}
render_partial_response?
end
), __FILE__, __LINE__
RUBY
else
module_eval %(
module_eval <<-RUBY, __FILE__, __LINE__ + 1
def index
if searching?
search_all_#{plural_name}
@@ -251,31 +251,31 @@ def index
render_partial_response?
end
), __FILE__, __LINE__
RUBY
end
else
if options[:paging]
module_eval %(
module_eval <<-RUBY, __FILE__, __LINE__ + 1
def index
paginate_all_#{plural_name}
render_partial_response?
end
), __FILE__, __LINE__
RUBY
else
module_eval %(
module_eval <<-RUBY, __FILE__, __LINE__ + 1
def index
find_all_#{plural_name}
render_partial_response?
end
), __FILE__, __LINE__
RUBY
end
end
if options[:sortable]
module_eval %(
module_eval <<-RUBY, __FILE__, __LINE__ + 1
def reorder
find_all_#{plural_name}
end
@@ -333,10 +333,10 @@ def after_update_positions
end
protected :after_update_positions
), __FILE__, __LINE__
RUBY
end
module_eval %(
module_eval <<-RUBY, __FILE__, __LINE__ + 1
class << self
def pageable?
#{options[:paging]}
@@ -351,8 +351,7 @@ def searchable?
#{options[:searchable]}
end
end
), __FILE__, __LINE__
RUBY
end
end

0 comments on commit 698554d

Please sign in to comment.