Sha256: 913fdc4881f34484fdfb1d2585ca1ff2d0f72bec98d13a41119c4918d4042cf5

Contents?: true

Size: 1.08 KB

Versions: 26

Compression:

Stored size: 1.08 KB

Contents

require 'custom_attributes/custom_attributes_api_helper'

module CustomAttributes
  module ControllerHelper
    module Customizable
      def self.all_available_fields(customizable_type)
        customizable = customizable_type
        if customizable_type.is_a? String
          customizable = get_customizable_class_or_fail(customizable_type).new
        end

        customizable.available_custom_fields
      end

      def self.all_values(customizable)
        customizable.custom_field_values
      end

      def self.value_by_field_id(customizable, field_id)
        customizable.populated_custom_field_value(field_id)
      end

      def self.update_field_value(customizable, field_id, value)
        to_change = { field_id => value }
        customizable.custom_field_values = to_change
        customizable.save!

        customizable.custom_value_for(field_id)
      end
    end

    module CustomField
      def self.increment_position(field)
        field.increment_position
      end

      def self.decrement_position(field)
        field.decrement_position
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
create_custom_attributes-0.6.3 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.6.2 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.6.1 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.25 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.24 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.23 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.22 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.21 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.20 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.19 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.18 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.17 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.16 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.15 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.14 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.13 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.12 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.11 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.10 lib/custom_attributes/api/custom_attributes_controller_helper.rb
create_custom_attributes-0.5.9 lib/custom_attributes/api/custom_attributes_controller_helper.rb