Permalink
Browse files

style [ci skip]

  • Loading branch information...
1 parent 991ed59 commit bc9cf10e07a0a62126af7c5d6b480292004b5ac4 @bbenezech bbenezech committed Oct 12, 2012
@@ -15,7 +15,7 @@ def association
@properties
end
- register_instance_option(:pretty_value) do
+ register_instance_option :pretty_value do
v = bindings[:view]
[value].flatten.select(&:present?).map do |associated|
amc = polymorphic? ? RailsAdmin.config(associated) : associated_model_config # perf optimization for non-polymorphic associations
@@ -29,12 +29,12 @@ def association
# Accessor whether association is visible or not. By default
# association checks whether the child model is excluded in
# configuration or not.
- register_instance_option(:visible?) do
+ register_instance_option :visible? do
@visible ||= !self.associated_model_config.excluded?
end
# use the association name as a key, not the association key anymore!
- register_instance_option(:label) do
+ register_instance_option :label do
(@label ||= {})[::I18n.locale] ||= abstract_model.model.human_attribute_name association[:name]
end
@@ -237,14 +237,14 @@ def errors
# Reader whether field is optional.
#
- # @see RailsAdmin::Config::Fields::Base.register_instance_option(:required?)
+ # @see RailsAdmin::Config::Fields::Base.register_instance_option :required?
def optional?
not required?
end
# Inverse accessor whether this field is required.
#
- # @see RailsAdmin::Config::Fields::Base.register_instance_option(:required?)
+ # @see RailsAdmin::Config::Fields::Base.register_instance_option :required?
def optional(state = nil, &block)
if !state.nil? || block
required state.nil? ? proc { false == (instance_eval &block) } : false == state
@@ -12,16 +12,16 @@ class Boolean < RailsAdmin::Config::Fields::Base
:check_box
end
- register_instance_option(:formatted_value) do
+ register_instance_option :formatted_value do
bindings[:view].image_tag("rails_admin/#{value ? 'bullet_black' : 'bullet_white'}.png", :alt => value.to_s)
end
- register_instance_option(:export_value) do
+ register_instance_option :export_value do
value.to_s
end
# Accessor for field's help text displayed below input field.
- register_instance_option(:help) do
+ register_instance_option :help do
""
end
end
@@ -8,21 +8,21 @@ class BsonObjectId < RailsAdmin::Config::Fields::Types::String
# Register field type for the type loader
RailsAdmin::Config::Fields::Types::register(self)
- register_instance_option(:label) do
+ register_instance_option :label do
label = ((@label ||= {})[::I18n.locale] ||= abstract_model.model.human_attribute_name name)
label = "Id" if label == ''
label
end
- register_instance_option(:help) do
+ register_instance_option :help do
"BSON::ObjectId"
end
- register_instance_option(:read_only) do
+ register_instance_option :read_only do
true
end
- register_instance_option(:sort_reverse?) do
+ register_instance_option :sort_reverse? do
serial?
end
@@ -8,15 +8,15 @@ module Types
class Carrierwave < RailsAdmin::Config::Fields::Types::FileUpload
RailsAdmin::Config::Fields::Types.register(self)
- register_instance_option(:thumb_method) do
+ register_instance_option :thumb_method do
@thumb_method ||= ((versions = bindings[:object].send(name).versions.keys).find{|k| k.in?([:thumb, :thumbnail, 'thumb', 'thumbnail'])} || versions.first.to_s)
end
- register_instance_option(:delete_method) do
+ register_instance_option :delete_method do
"remove_#{name}"
end
- register_instance_option(:cache_method) do
+ register_instance_option :cache_method do
"#{name}_cache"
end
@@ -133,27 +133,27 @@ def parse_input(params)
params[name] = self.class.normalize(params[name], "#{localized_date_format} #{localized_time_format}") if params[name].present?
end
- register_instance_option(:sort_reverse?) do
+ register_instance_option :sort_reverse? do
true
end
- register_instance_option(:date_format) do
+ register_instance_option :date_format do
self.class.format
end
- register_instance_option(:formatted_value) do
+ register_instance_option :formatted_value do
unless (time = value).nil?
I18n.l(time, :format => strftime_format)
else
"".html_safe
end
end
- register_instance_option(:partial) do
+ register_instance_option :partial do
:form_datetime
end
- register_instance_option(:strftime_format) do
+ register_instance_option :strftime_format do
localized_format self.class.i18n_scope
end
end
@@ -7,19 +7,19 @@ module Types
class Enum < RailsAdmin::Config::Fields::Base
RailsAdmin::Config::Fields::Types::register(self)
- register_instance_option(:partial) do
+ register_instance_option :partial do
:form_enumeration
end
- register_instance_option(:enum_method) do
+ register_instance_option :enum_method do
@enum_method ||= (bindings[:object].class.respond_to?("#{name}_enum") || bindings[:object].respond_to?("#{name}_enum")) ? "#{name}_enum" : name
end
- register_instance_option(:enum) do
+ register_instance_option :enum do
bindings[:object].class.respond_to?(enum_method) ? bindings[:object].class.send(enum_method) : bindings[:object].send(enum_method)
end
- register_instance_option(:pretty_value) do
+ register_instance_option :pretty_value do
if enum.is_a?(::Hash)
enum.reject{|k,v| v.to_s != value.to_s}.keys.first.to_s.presence || value.presence || ' - '
elsif enum.is_a?(::Array) && enum.first.is_a?(::Array)
@@ -29,7 +29,7 @@ class Enum < RailsAdmin::Config::Fields::Base
end
end
- register_instance_option(:multiple?) do
+ register_instance_option :multiple? do
properties && [:serialized].include?(properties[:type])
end
end
@@ -7,27 +7,27 @@ module Types
class FileUpload < RailsAdmin::Config::Fields::Base
RailsAdmin::Config::Fields::Types::register(self)
- register_instance_option(:partial) do
- :form_file_upload
- end
-
- register_instance_option(:thumb_method) do
- nil
- end
-
- register_instance_option(:delete_method) do
- nil
- end
-
- register_instance_option(:cache_method) do
- nil
- end
-
- register_instance_option(:export_value) do
- resource_url.to_s
- end
-
- register_instance_option(:pretty_value) do
+ register_instance_option :partial do
+ :form_file_upload
+ end
+
+ register_instance_option :thumb_method do
+ nil
+ end
+
+ register_instance_option :delete_method do
+ nil
+ end
+
+ register_instance_option :cache_method do
+ nil
+ end
+
+ register_instance_option :export_value do
+ resource_url.to_s
+ end
+
+ register_instance_option :pretty_value do
if value.presence
v = bindings[:view]
url = resource_url
@@ -13,7 +13,7 @@ class HasOneAssociation < RailsAdmin::Config::Fields::Association
end
# Accessor for field's formatted value
- register_instance_option(:formatted_value) do
+ register_instance_option :formatted_value do
(o = value) && o.send(associated_model_config.object_label_method)
end
@@ -12,7 +12,7 @@ class Integer < RailsAdmin::Config::Fields::Base
:number_field
end
- register_instance_option(:sort_reverse?) do
+ register_instance_option :sort_reverse? do
serial?
end
end
@@ -9,11 +9,11 @@ module Types
class Paperclip < RailsAdmin::Config::Fields::Types::FileUpload
RailsAdmin::Config::Fields::Types.register(self)
- register_instance_option(:delete_method) do
+ register_instance_option :delete_method do
"delete_#{name}" if bindings[:object].respond_to?("delete_#{name}")
end
- register_instance_option(:thumb_method) do
+ register_instance_option :thumb_method do
@styles ||= bindings[:object].send(name).styles.map(&:first)
@thumb_method ||= @styles.find{|s| [:thumb, 'thumb', :thumbnail, 'thumbnail'].include?(s)} || @styles.first || :original
end
@@ -8,22 +8,22 @@ class PolymorphicAssociation < RailsAdmin::Config::Fields::Types::BelongsToAssoc
# Register field type for the type loader
RailsAdmin::Config::Fields::Types::register(self)
- register_instance_option(:partial) do
+ register_instance_option :partial do
:form_polymorphic_association
end
# Accessor whether association is visible or not. By default
# association checks that any of the child models are included in
# configuration.
- register_instance_option(:visible?) do
+ register_instance_option :visible? do
associated_model_config.length > 0
end
- register_instance_option(:sortable) do
+ register_instance_option :sortable do
false
end
- register_instance_option(:searchable) do
+ register_instance_option :searchable do
false
end
@@ -8,14 +8,14 @@ class String < RailsAdmin::Config::Fields::Base
RailsAdmin::Config::Fields::Types::register(self)
- register_instance_option(:html_attributes) do
+ register_instance_option :html_attributes do
{
:maxlength => length,
:size => [50, length.to_i].min
}
end
- register_instance_option(:help) do
+ register_instance_option :help do
text = (required? ? I18n.translate("admin.form.required") : I18n.translate("admin.form.optional")) + '. '
if valid_length.present? && valid_length[:is].present?
text += "#{I18n.translate("admin.form.char_length_of").capitalize} #{valid_length[:is]}."
@@ -33,7 +33,7 @@ class String < RailsAdmin::Config::Fields::Base
text
end
- register_instance_option(:partial) do
+ register_instance_option :partial do
:form_field
end
end
Oops, something went wrong.

0 comments on commit bc9cf10

Please sign in to comment.