Module: FlexAttributes::InstanceMethods
- Defined in:
- lib/flex-attributes.rb
Instance Method Summary collapse
-
#flex_attributes(model) ⇒ Object
Return a list of valid flex attributes for the given model.
-
#is_flex_attribute?(attr, model) ⇒ Boolean
Will determine if the given attribute is a flex attribute on the given model.
Instance Method Details
#flex_attributes(model) ⇒ Object
Return a list of valid flex 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.
347 |
# File 'lib/flex-attributes.rb', line 347 def flex_attributes(model); nil end |
#is_flex_attribute?(attr, model) ⇒ Boolean
Will determine if the given attribute is a flex attribute on the given model. Override this in your class to provide custom logic if the #flex_attributes method or the :fields option are not flexible enough. If you override this method :fields and #flex_attributes will not apply at all unless you implement them yourself.
334 335 336 337 338 339 340 341 |
# File 'lib/flex-attributes.rb', line 334 def is_flex_attribute?(attr, model) attr = attr.to_s return [model.name][:fields].include?(attr) unless [model.name][:fields].nil? return flex_attributes(model).collect {|f| f.to_s}.include?(attr) unless flex_attributes(model).nil? true end |