class Scorpion::Attribute
An injected attribute and it's configuration.
Attributes
name[R]
@!attribute @return [Symbol] the name of the attribute.
Public Class Methods
new( name, contract, lazy: false, public: false, private: false )
click to toggle source
@!endgroup Attributes
# 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
Public Instance Methods
contract()
click to toggle source
@!attribute @return [Class,Module,Symbol] contract that describes the desired behavior
of the injected object.
# File lib/scorpion/attribute.rb, line 16 def contract @contract = @contract.constantize if @contract.is_a? String @contract end
lazy?()
click to toggle source
@!attribute @return [Boolean] true if the attribute is not immediately required and
will be hunted down on first use.
# File lib/scorpion/attribute.rb, line 24 def lazy? @lazy end
private?()
click to toggle source
@!attribute @return [Boolean] true if the attribute should have a public writer.
# File lib/scorpion/attribute.rb, line 36 def private? @private end
public?()
click to toggle source
@!attribute @return [Boolean] true if the attribute should have a public writer.
# File lib/scorpion/attribute.rb, line 30 def public? @public end