Top Level Namespace
Defined Under Namespace
Modules: ActiveModel, MongoMapper
Classes: WhinyAttrAccessibleError
Instance Method Summary
collapse
Instance Method Details
#check_and_raise_if_diffs(attrs, safe_attrs) ⇒ Object
1
2
3
4
5
6
7
8
9
10
|
# File 'lib/util/print_diffs.rb', line 1
def check_and_raise_if_diffs(attrs, safe_attrs)
diff = attrs.flatten - safe_attrs.flatten
return if diff.blank?
results = []
diff.length.times do |idx|
next if idx % 2 != 0
results << "#{diff[idx]} => #{diff[idx + 1]}"
end
raise WhinyAttrAccessibleError.new("You tried to assign the following attributes that are either protected or not accessible: #{results.join(", ")}")
end
|
#development_or_test? ⇒ Boolean
1
2
3
4
|
# File 'lib/util/helpers.rb', line 1
def development_or_test?
return true unless defined?(Rails)
Rails.env.development? || Rails.env.test?
end
|
#my_alias_method_chain(original, aliased) ⇒ Object
6
7
8
9
|
# File 'lib/util/helpers.rb', line 6
def my_alias_method_chain(original, aliased)
alias_method "#{original}_without_#{aliased}", original
alias_method original, "#{original}_with_#{aliased}"
end
|