Module: Traits::Attribute::Type
- Included in:
- Traits::Attribute
- Defined in:
- lib/traits/attribute/type.rb
Instance Method Summary collapse
- #active_record_timestamp? ⇒ Boolean
- #big? ⇒ Boolean
- #binary? ⇒ Boolean
- #datetime? ⇒ Boolean
- #decimal? ⇒ Boolean
- #float? ⇒ Boolean
- #integer? ⇒ Boolean
- #number? ⇒ Boolean
- #real? ⇒ Boolean
- #string? ⇒ Boolean
- #text? ⇒ Boolean
- #to_hash ⇒ Object
- #type ⇒ Object
Instance Method Details
#active_record_timestamp? ⇒ Boolean
51 52 53 |
# File 'lib/traits/attribute/type.rb', line 51 def datetime? && (name == :created_at || name == :updated_at || name == :deleted_at) end |
#big? ⇒ Boolean
23 24 25 |
# File 'lib/traits/attribute/type.rb', line 23 def big? text? || binary? end |
#binary? ⇒ Boolean
19 20 21 |
# File 'lib/traits/attribute/type.rb', line 19 def binary? type == :binary end |
#datetime? ⇒ Boolean
47 48 49 |
# File 'lib/traits/attribute/type.rb', line 47 def datetime? type == :datetime end |
#decimal? ⇒ Boolean
35 36 37 |
# File 'lib/traits/attribute/type.rb', line 35 def decimal? type == :decimal end |
#float? ⇒ Boolean
31 32 33 |
# File 'lib/traits/attribute/type.rb', line 31 def float? type == :float end |
#integer? ⇒ Boolean
27 28 29 |
# File 'lib/traits/attribute/type.rb', line 27 def integer? type == :integer end |
#number? ⇒ Boolean
43 44 45 |
# File 'lib/traits/attribute/type.rb', line 43 def number? integer? || float? || decimal? end |
#real? ⇒ Boolean
39 40 41 |
# File 'lib/traits/attribute/type.rb', line 39 def real? float? || decimal? end |
#string? ⇒ Boolean
11 12 13 |
# File 'lib/traits/attribute/type.rb', line 11 def string? type == :string end |
#text? ⇒ Boolean
15 16 17 |
# File 'lib/traits/attribute/type.rb', line 15 def text? type == :text end |
#to_hash ⇒ Object
55 56 57 58 59 |
# File 'lib/traits/attribute/type.rb', line 55 def to_hash super.merge!( type: type ) end |
#type ⇒ Object
7 8 9 |
# File 'lib/traits/attribute/type.rb', line 7 def type @type ||= column_definition.type.to_sym end |