Module: ClosureTree::SupportFlags
- Included in:
- Support
- Defined in:
- lib/closure_tree/support_flags.rb
Instance Method Summary collapse
- #has_name? ⇒ Boolean
- #has_type? ⇒ Boolean
- #include_forbidden_attributes_protection? ⇒ Boolean
- #order_is_numeric? ⇒ Boolean
- #order_option? ⇒ Boolean
- #subclass? ⇒ Boolean
- #use_attr_accessible? ⇒ Boolean
Instance Method Details
#has_name? ⇒ Boolean
36 37 38 |
# File 'lib/closure_tree/support_flags.rb', line 36 def has_name? model_class.new.attributes.include? [:name_column] end |
#has_type? ⇒ Boolean
32 33 34 |
# File 'lib/closure_tree/support_flags.rb', line 32 def has_type? attribute_names.include? 'type' end |
#include_forbidden_attributes_protection? ⇒ Boolean
11 12 13 14 15 |
# File 'lib/closure_tree/support_flags.rb', line 11 def include_forbidden_attributes_protection? ActiveRecord::VERSION::MAJOR == 3 && defined?(ActiveModel::ForbiddenAttributesProtection) && model_class.ancestors.include?(ActiveModel::ForbiddenAttributesProtection) end |
#order_is_numeric? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/closure_tree/support_flags.rb', line 21 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
17 18 19 |
# File 'lib/closure_tree/support_flags.rb', line 17 def order_option? ![:order].nil? end |
#subclass? ⇒ Boolean
28 29 30 |
# File 'lib/closure_tree/support_flags.rb', line 28 def subclass? model_class != model_class.base_class end |
#use_attr_accessible? ⇒ Boolean
4 5 6 7 8 9 |
# File 'lib/closure_tree/support_flags.rb', line 4 def use_attr_accessible? ActiveRecord::VERSION::MAJOR == 3 && defined?(ActiveModel::MassAssignmentSecurity) && model_class.respond_to?(:accessible_attributes) && model_class.accessible_attributes.present? end |