Module: ClosureTree::SupportFlags

Included in:
Support
Defined in:
lib/closure_tree/support_flags.rb

Instance Method Summary collapse

Instance Method Details

#has_inheritance_column?(hash = columns_hash) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/closure_tree/support_flags.rb', line 27

def has_inheritance_column?(hash = columns_hash)
  hash.with_indifferent_access.include?(model_class.inheritance_column)
end

#has_name?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/closure_tree/support_flags.rb', line 31

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

#include_forbidden_attributes_protection?Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/closure_tree/support_flags.rb', line 10

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

#order_is_numeric?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/closure_tree/support_flags.rb', line 19

def order_is_numeric?
  options[:numeric_order]
end

#order_option?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/closure_tree/support_flags.rb', line 15

def order_option?
  order_by.present?
end

#subclass?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/closure_tree/support_flags.rb', line 23

def subclass?
  model_class != model_class.base_class
end

#use_attr_accessible?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
# File 'lib/closure_tree/support_flags.rb', line 4

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