Sha256: 72b448074b8c0e1ebba9082463107152546496f9f4647674f63bc89cbfc6c03c

Contents?: true

Size: 861 Bytes

Versions: 3

Compression:

Stored size: 861 Bytes

Contents

module BaseModels

  class Person
    include CleanModel::Base

    attribute :first_name
    attribute :last_name
    attribute :nationality, default: :argentina
    attribute :age, default: -> { Time.now.year - 1979 }
    attribute :married, default: false

    validates_presence_of :first_name, :last_name
  end

  class Engine
    include CleanModel::Base

    attribute :power, class_name: :numeric
    attribute :cylinders, class_name: :integer
    attribute :valves, class_name: 'Integer'
  end

  class Car
    include CleanModel::Base

    attribute :brand
    attribute :model
    attribute :engine, class_name: 'BaseModels::Engine'
    attribute :comfort, transformation: lambda { |v| v.is_a?(String) ? v.split(',').map(&:strip) : v }
  end

  class Factory
    include CleanModel::Base

    attribute :cars, collection: 'BaseModels::Car'
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clean_model-0.0.9 spec/support/models/base_models.rb
clean_model-0.0.8 spec/support/models/base_models.rb
clean_model-0.0.7 spec/support/models/base_models.rb