Sha256: bad48a0c2a1a773906b098b59e0255e60e61252999888a28e19057e9b3747926

Contents?: true

Size: 1017 Bytes

Versions: 5

Compression:

Stored size: 1017 Bytes

Contents

module ClosureTree
  module SupportFlags

    def use_attr_accessible?
      defined?(ActiveModel::MassAssignmentSecurity) &&
        model_class.respond_to?(:accessible_attributes) &&
        model_class.accessible_attributes.present?
    end

    def include_forbidden_attributes_protection?
      defined?(ActiveModel::ForbiddenAttributesProtection) &&
        model_class.ancestors.include?(ActiveModel::ForbiddenAttributesProtection)
    end

    def order_option?
      order_by.present?
    end

    def order_is_numeric?
      # The table might not exist yet (in the case of ActiveRecord::Observer use, see issue 32)
      return false if !order_option? || !model_class.table_exists?
      c = model_class.columns_hash[order_column]
      c && c.type == :integer
    end

    def subclass?
      model_class != model_class.base_class
    end

    def has_type?
      attribute_names.include? 'type'
    end

    def has_name?
      model_class.new.attributes.include? options[:name_column]
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
closure_tree-4.2.7 lib/closure_tree/support_flags.rb
closure_tree-4.2.6 lib/closure_tree/support_flags.rb
closure_tree-4.2.5 lib/closure_tree/support_flags.rb
closure_tree-4.2.4 lib/closure_tree/support_flags.rb
closure_tree-4.2.3 lib/closure_tree/support_flags.rb