Class: Scorpion::Attribute

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

Overview

An injected attribute and it’s configuration.

Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, contract, lazy: false, public: false, private: false) ⇒ Attribute

Returns a new instance of Attribute.



44
45
46
47
48
49
50
# File 'lib/scorpion/attribute.rb', line 44

def initialize( name, contract, lazy: false, public: false, private: false )
  @name      = name.to_sym
  @contract  = contract
  @lazy      = lazy
  @public    = public
  @private   = private
end

Instance Attribute Details

#nameSymbol

Returns the name of the attribute.

Returns:

  • (Symbol)

    the name of the attribute.



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

def name
  @name
end

Instance Method Details

#contractObject



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

def contract
  @contract = @contract.constantize if @contract.is_a? String
  @contract
end

#lazy?Object



24
25
26
# File 'lib/scorpion/attribute.rb', line 24

def lazy?
  @lazy
end

#private?Object



36
37
38
# File 'lib/scorpion/attribute.rb', line 36

def private?
  @private
end

#public?Object



30
31
32
# File 'lib/scorpion/attribute.rb', line 30

def public?
  @public
end