Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code style refactor #1546

Merged
merged 1 commit into from Aug 22, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/active_admin/application.rb
Expand Up @@ -242,7 +242,7 @@ def register_default_assets
register_stylesheet 'active_admin.css', :media => 'screen'
register_stylesheet 'active_admin/print.css', :media => 'print'

if !ActiveAdmin.use_asset_pipeline?
unless ActiveAdmin.use_asset_pipeline?
register_javascript 'jquery.min.js'
register_javascript 'jquery-ui.min.js'
register_javascript 'jquery_ujs.js'
Expand Down
2 changes: 1 addition & 1 deletion lib/active_admin/engine.rb
Expand Up @@ -2,7 +2,7 @@ module ActiveAdmin
class Engine < Rails::Engine
if Rails.version > "3.1"
initializer "ActiveAdmin precompile hook" do |app|
app.config.assets.precompile += ['active_admin.js', 'active_admin.css', 'active_admin/print.css']
app.config.assets.precompile += %w(active_admin.js active_admin.css active_admin/print.css)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/active_admin/filters/forms.rb
Expand Up @@ -17,7 +17,7 @@ def filter(method, options = {})

# Returns the default filter type for a given attribute
def default_input_type(method, options = {})
if column = column_for(method)
if (column = column_for(method))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't usually do this. I guess it's a matter of taste? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe :) Everyone follows his style. But Github recommends doing so https://github.com/styleguide/ruby/. In this particular case may be obvious whether a value is assigned to a variable or two variables are compared. You decide.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub FTW!

case column.type
when :date, :datetime
return :date_range
Expand All @@ -31,7 +31,7 @@ def default_input_type(method, options = {})
end
end

if reflection = reflection_for(method)
if (reflection = reflection_for(method))
return :select if reflection.macro == :belongs_to && !reflection.options[:polymorphic]
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_admin/router.rb
Expand Up @@ -97,7 +97,7 @@ def apply(router)
end

# Add on the namespace if required
if !config.namespace.root?
unless config.namespace.root?
routes_in_namespace = route_definition_block.dup
route_definition_block = Proc.new do
namespace config.namespace.name do
Expand Down
3 changes: 2 additions & 1 deletion lib/active_admin/view_helpers/auto_link_helper.rb
Expand Up @@ -13,10 +13,11 @@ module AutoLinkHelper
#
def auto_link(resource, link_content = nil)
content = link_content || display_name(resource)
if registration = active_admin_resource_for(resource.class)
if (registration = active_admin_resource_for(resource.class))
begin
content = link_to(content, send(registration.route_instance_path, resource))
rescue
# ignored
end
end
content
Expand Down
3 changes: 2 additions & 1 deletion lib/active_admin/view_helpers/breadcrumb_helper.rb
Expand Up @@ -10,12 +10,13 @@ def breadcrumb_links(path = nil)
crumbs = []
parts.each_with_index do |part, index|
name = nil
if part =~ /^\d|^[a-f0-9]{24}$/ && parent = parts[index - 1]
if part =~ /^\d|^[a-f0-9]{24}$/ && (parent = parts[index - 1])
begin
parent_class = parent.singularize.camelcase.constantize
obj = parent_class.find(part[/^[a-f0-9]{24}$/] ? part : part.to_i)
name = display_name(obj)
rescue
# ignored
end
end

Expand Down