Module | Cms::Behaviors::DynamicAttributes::InstanceMethods |
In: |
lib/cms/behaviors/dynamic_attributes.rb
|
Return a list of valid dynamic attributes for the given model. Return nil if any field is allowed. If you want to say no field is allowed then return an empty array. If you just have a static list the :fields option is most likely easier.
# File lib/cms/behaviors/dynamic_attributes.rb, line 217 217: def dynamic_attributes(model); nil end
Will determine if the given attribute is a dynamic attribute on the given model. Override this in your class to provide custom logic if the dynamic_attributes method or the :fields option are not flexible enough. If you override this method :fields and dynamic_attributes will not apply at all unless you implement them yourself.
# File lib/cms/behaviors/dynamic_attributes.rb, line 204 204: def is_dynamic_attribute?(attr, model) 205: attr = attr.to_s 206: return dynamic_options[model.name][:fields].include?(attr) unless 207: dynamic_options[model.name][:fields].nil? 208: return dynamic_attributes(model).collect {|f| f.to_s}.include?(attr) unless 209: dynamic_attributes(model).nil? 210: true 211: end