Minor code cleanup

80 characters screen width
This commit is contained in:
jonatack 2013-12-15 18:51:48 +01:00
parent 1e24b60906
commit cb84f7f7b5
3 changed files with 8 additions and 4 deletions

View File

@ -21,8 +21,8 @@ module Ransack
end end
def valid? def valid?
bound? && attr && bound? && attr && context.klassify(parent)
context.klassify(parent).ransackable_attributes(context.auth_object).include?(attr_name) .ransackable_attributes(context.auth_object).include?(attr_name)
end end
def type def type

View File

@ -5,7 +5,9 @@ module Ransack
attr_accessor :parent, :attr_name attr_accessor :parent, :attr_name
def attr def attr
@attr ||= ransacker ? ransacker.attr_from(self) : context.table_for(parent)[attr_name] @attr ||= ransacker ?
ransacker.attr_from(self) :
context.table_for(parent)[attr_name]
end end
alias :arel_attribute :attr alias :arel_attribute :attr

View File

@ -29,7 +29,9 @@ module Ransack
end end
def name_from_attribute_name(attribute_name) def name_from_attribute_name(attribute_name)
names_by_decreasing_length.detect { |p| attribute_name.to_s.match(/_#{p}$/) } names_by_decreasing_length.detect {
|p| attribute_name.to_s.match(/_#{p}$/)
}
end end
def for_attribute_name(attribute_name) def for_attribute_name(attribute_name)