module StringAttributes::Base::ClassMethods
Public Instance Methods
attr_string(attribute, options = {})
click to toggle source
# File lib/string_attributes/base.rb, line 13 def attr_string(attribute, options = {}) validate_attribute!(attribute) set_strip(attribute) if options[:strip] end
Private Instance Methods
validate_attribute!(attribute)
click to toggle source
# File lib/string_attributes/base.rb, line 21 def validate_attribute!(attribute) unless attribute.is_a?(String) || attribute.is_a?(Symbol) fail StringAttributes::InvalidArgument, 'Attribute must be String or Symbol' end unless self.column_names.include? attribute.to_s fail StringAttributes::UnkownAttribute, "#{self.name} does not have #{attribute}" end true end