Module: Formed::Attributes
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #_has_attribute?(name) ⇒ Boolean
- #attribute_present?(attr_name) ⇒ Boolean
- #attributes_with_values ⇒ Object
- #column_for_attribute(attr) ⇒ Object
- #has_attribute?(attr_name) ⇒ Boolean
- #type_for_attribute(attr) ⇒ Object
Instance Method Details
#_has_attribute?(name) ⇒ Boolean
7 8 9 |
# File 'lib/formed/attributes.rb', line 7 def _has_attribute?(name) attributes.key?(name) end |
#attribute_present?(attr_name) ⇒ Boolean
11 12 13 14 15 16 |
# File 'lib/formed/attributes.rb', line 11 def attribute_present?(attr_name) attr_name = attr_name.to_s attr_name = self.class.attribute_aliases[attr_name] || attr_name value = _read_attribute(attr_name) !value.nil? && !(value.respond_to?(:empty?) && value.empty?) end |
#attributes_with_values ⇒ Object
32 33 34 |
# File 'lib/formed/attributes.rb', line 32 def attributes_with_values attributes.select { |_, v| v.present? } end |
#column_for_attribute(attr) ⇒ Object
22 23 24 |
# File 'lib/formed/attributes.rb', line 22 def column_for_attribute(attr) model.column_for_attribute(attr) end |
#has_attribute?(attr_name) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/formed/attributes.rb', line 26 def has_attribute?(attr_name) attr_name = attr_name.to_s attr_name = self.class.attribute_aliases[attr_name] || attr_name @attributes.key?(attr_name) end |
#type_for_attribute(attr) ⇒ Object
18 19 20 |
# File 'lib/formed/attributes.rb', line 18 def type_for_attribute(attr) self.class.attribute_types[attr].type end |