Sha256: 75cc78095233f101befd330e6dc035e0a237946bd9b671794026f4e218e1145a
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
module Hancock::Gallery module Admin # images_block(is_active = false, fields = [:images], options = {}) # images_block(is_active = false, options = {field: [:images]}) # images_block(fields = [:images], options = {active: false}) # images_block(options = {fields: [:images], active: false}) # images_block(is_active = false, fields = [:images], options = {}) def self.images_block(is_active = false, fields = [:images], options = {}) if is_active.is_a?(Array) or is_active.is_a?(String) or is_active.is_a?(Symbol) is_active, fields = false, [is_active].flatten elsif is_active.is_a?(Hash) is_active, fields = (is_active[:active] || false), (is_active[:fields] || [:images]) elsif fields.is?(Hash) is_active, fields, options = (fields[:active] || false), (is_active[:fields] || [:images]), fields end if fields.is_a?(Array) fields.map! { |f| if f.is_a?(Hash) f elsif f.is_a?(Array) _ret = {"#{f.first}" => f[1..-1]} else { "#{f}": nil } end } fields = fields.reduce({}, :merge) end Proc.new { active is_active label options[:label] || I18n.t('hancock.images') field :image, :hancock_image Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields) if block_given? yield self end } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hancock_cms_gallery-1.0.2 | lib/hancock/gallery/admin.rb |