Class: Recliner::Property

Inherits:
Struct
  • Object
show all
Defined in:
lib/recliner/properties/property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#asObject

Returns the value of attribute as

Returns:

  • (Object)

    the current value of as



5
6
7
# File 'lib/recliner/properties/property.rb', line 5

def as
  @as
end

#defaultObject

Returns the value of attribute default

Returns:

  • (Object)

    the current value of default



5
6
7
# File 'lib/recliner/properties/property.rb', line 5

def default
  @default
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/recliner/properties/property.rb', line 5

def name
  @name
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



5
6
7
# File 'lib/recliner/properties/property.rb', line 5

def type
  @type
end

Instance Method Details

#default_value(instance) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/recliner/properties/property.rb', line 6

def default_value(instance)
  if default.respond_to?(:call)
    default.arity == 1 ? default.call(instance) : default.call
  else
    default.duplicable? ? default.dup : default
  end
end

#type_cast(value) ⇒ Object



14
15
16
# File 'lib/recliner/properties/property.rb', line 14

def type_cast(value)
  Conversions.convert(value, type)
end