Skip to content

Commit

Permalink
Better syntax highlighting in crudify
Browse files Browse the repository at this point in the history
  • Loading branch information
bricesanchez authored and parndt committed Sep 11, 2018
1 parent 0dec51a commit 698554d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions core/lib/refinery/crud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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]}
Expand All @@ -351,8 +351,7 @@ def searchable?
#{options[:searchable]}
end
end
), __FILE__, __LINE__

RUBY
end

end
Expand Down

0 comments on commit 698554d

Please sign in to comment.