Module: Lotus::Validations::AttributeDefiner::EntityAttributeDefiner Private

Defined in:
lib/lotus/validations/attribute_definer.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Support for ‘Lotus::Entity`

Examples:

require 'lotus/model'
require 'lotus/validations'

class Product
  include Lotus::Entity
  include Lotus::Validations

  attribute :name,  type: String,  presence: true
  attribute :price, type: Integer, presence: true
end

product = Product.new(name: 'Computer', price: '100')

product.name   # => "Computer"
product.price  # => 100
product.valid? # => true

Since:

  • 0.2.3

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Override for Module#extend



405
406
407
408
409
# File 'lib/lotus/validations/attribute_definer.rb', line 405

def self.extended(base)
  base.class_eval do
    include EntityAttributeDefiner::InstanceMethods
  end
end

Instance Method Details

#attribute(name, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Also:

  • Lotus::Validations::AttributeDefiner#attribute

Since:

  • 0.2.3



435
436
437
438
# File 'lib/lotus/validations/attribute_definer.rb', line 435

def attribute(name, options = {})
  attributes name
  super
end

#define_attr_accessor(attr) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Override attribute accessors function.

See Also:

  • Model::Entity#define_attr_accessor

Since:

  • 0.3.1



426
427
428
429
# File 'lib/lotus/validations/attribute_definer.rb', line 426

def define_attr_accessor(attr)
  _attribute(attr)
  super
end

#defined_attributesArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<String>)

Since:

  • 0.3.1



415
416
417
418
# File 'lib/lotus/validations/attribute_definer.rb', line 415

def defined_attributes
  super
  @defined_attributes.merge(attributes.map(&:to_s))
end

#validates(name, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Also:

Since:

  • 0.2.3



444
445
446
447
# File 'lib/lotus/validations/attribute_definer.rb', line 444

def validates(name, options = {})
  super
  define_attribute(name, options)
end