Method: Cms::Behaviors::DynamicAttributes::InstanceMethods#is_dynamic_attribute?

Defined in:
lib/cms/behaviors/dynamic_attributes.rb

#is_dynamic_attribute?(attr, model) ⇒ Boolean

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.

Returns:

  • (Boolean)


209
210
211
212
213
214
# File 'lib/cms/behaviors/dynamic_attributes.rb', line 209

def is_dynamic_attribute?(attr, model)
  attr = attr.to_s
  return dynamic_options[model.name][:fields].include?(attr) unless dynamic_options[model.name][:fields].nil?
  return dynamic_attributes(model).collect { |f| f.to_s }.include?(attr) unless dynamic_attributes(model).nil?
  true
end