Sha256: 7170b8ee07fb24f09ad3d5e90a44f8c6efc95195e1954d4f4a31675b77e2441d

Contents?: true

Size: 936 Bytes

Versions: 7

Compression:

Stored size: 936 Bytes

Contents

module ActionView
  module Helpers
    def setting_check_box(model_name, method, options = {}, checked_value = "1", unchecked_value = "0")
      the_model = @template.instance_variable_get("@#{model_name}")
      throw "No @#{model_name} in scope" if the_model.nil?
      throw "The setting_check_box only works on models with settings" unless the_model.respond_to?(:settings)
      options[:checked] = the_model.settings.send("#{method}?")
      options[:id]    ||= "#{model_name}_settings_#{method}"
      options[:name]    = "#{model_name}[settings][#{method}]"
      @template.check_box(model_name, "settings_#{method}", options, checked_value, unchecked_value)
    end

    class FormBuilder
      def setting_check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
        @template.setting_check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
property_sets-0.0.11 lib/property_sets/property_set_helper.rb
property_sets-0.0.10 lib/property_sets/property_set_helper.rb
property_sets-0.0.9 lib/property_sets/property_set_helper.rb
property_sets-0.0.8 lib/property_sets/property_set_helper.rb
property_sets-0.0.7 lib/property_sets/property_set_helper.rb
property_sets-0.0.6 lib/property_sets/property_set_helper.rb
has_settings-0.0.5 lib/has_settings/has_settings_helper.rb