Class: Shale::Attribute Private

Inherits:
Object
  • Object
show all
Defined in:
lib/shale/attribute.rb

Overview

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

Class representing object’s attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, collection, default) ⇒ Attribute

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.

Initialize Attribute object

Parameters:

  • name (Symbol)

    Name of the attribute

  • type (Shale::Type::Value)

    Type of the attribute

  • collection (Boolean)

    Is this attribute a collection

  • default (Proc)

    Default value



36
37
38
39
40
41
42
# File 'lib/shale/attribute.rb', line 36

def initialize(name, type, collection, default)
  @name = name
  @setter = "#{name}="
  @type = type
  @collection = collection
  @default = collection ? -> { [] } : default
end

Instance Attribute Details

#defaultObject (readonly)

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.

Return default



21
22
23
# File 'lib/shale/attribute.rb', line 21

def default
  @default
end

#nameObject (readonly)

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.

Return name



11
12
13
# File 'lib/shale/attribute.rb', line 11

def name
  @name
end

#setterObject (readonly)

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.

Return setter name



26
27
28
# File 'lib/shale/attribute.rb', line 26

def setter
  @setter
end

#typeObject (readonly)

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.

Return type



16
17
18
# File 'lib/shale/attribute.rb', line 16

def type
  @type
end

Instance Method Details

#collection?Boolean

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.

Return wheter attribute is collection or not

Returns:

  • (Boolean)


49
50
51
# File 'lib/shale/attribute.rb', line 49

def collection?
  @collection == true
end