Class: ObjectIdentifier::Parameters
Overview
ObjectIdentifier::Parameters encapsulates the attributes list and formatter options that may be needed for custom formatting during object identification.
Constant Summary collapse
- KLASS_NOT_GIVEN =
"NOT_GIVEN"
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(attributes: [], formatter_options: {}) ⇒ Parameters
constructor
A new instance of Parameters.
-
#klass ⇒ Object
NOTE: Expects a block if a value wasn’t supplied on initialization.
-
#limit ⇒ Object
NOTE: Expects a block if a value wasn’t supplied on initialization.
Constructor Details
#initialize(attributes: [], formatter_options: {}) ⇒ Parameters
Returns a new instance of Parameters.
94 95 96 97 98 99 100 |
# File 'lib/object_identifier.rb', line 94 def initialize( attributes: [], formatter_options: {}) @attributes = attributes @limit = .fetch(:limit, nil) @klass = .fetch(:klass, KLASS_NOT_GIVEN) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
86 87 88 |
# File 'lib/object_identifier.rb', line 86 def attributes @attributes end |
Instance Method Details
#klass ⇒ Object
NOTE: Expects a block if a value wasn’t supplied on initialization.
108 109 110 111 112 113 114 115 116 |
# File 'lib/object_identifier.rb', line 108 def klass if klass_given? @klass.to_s elsif block_given? yield.to_s else nil end end |
#limit ⇒ Object
NOTE: Expects a block if a value wasn’t supplied on initialization.
103 104 105 |
# File 'lib/object_identifier.rb', line 103 def limit @limit || (yield if block_given?) end |