Module: ClosureTree::SupportFlags
- Included in:
- Support
- Defined in:
- lib/closure_tree/support_flags.rb
Instance Method Summary collapse
- #has_inheritance_column?(hash = columns_hash) ⇒ Boolean
- #has_name? ⇒ Boolean
- #include_forbidden_attributes_protection? ⇒ Boolean
- #order_is_numeric? ⇒ Boolean
- #order_option? ⇒ Boolean
- #subclass? ⇒ Boolean
- #use_attr_accessible? ⇒ Boolean
Instance Method Details
#has_inheritance_column?(hash = columns_hash) ⇒ Boolean
30 31 32 |
# File 'lib/closure_tree/support_flags.rb', line 30 def has_inheritance_column?(hash = columns_hash) hash.with_indifferent_access.include?(model_class.inheritance_column) end |
#has_name? ⇒ Boolean
34 35 36 |
# File 'lib/closure_tree/support_flags.rb', line 34 def has_name? model_class.new.attributes.include? [:name_column] end |
#include_forbidden_attributes_protection? ⇒ 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
19 20 21 22 23 24 |
# File 'lib/closure_tree/support_flags.rb', line 19 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 |
#order_option? ⇒ Boolean
15 16 17 |
# File 'lib/closure_tree/support_flags.rb', line 15 def order_option? order_by.present? end |
#subclass? ⇒ Boolean
26 27 28 |
# File 'lib/closure_tree/support_flags.rb', line 26 def subclass? model_class != model_class.base_class end |
#use_attr_accessible? ⇒ 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 |