Class: Restspec::Schema::Attribute
- Inherits:
-
Object
- Object
- Restspec::Schema::Attribute
- Defined in:
- lib/restspec/schema/attribute.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #can_be_checked? ⇒ Boolean
- #can_generate_examples? ⇒ Boolean
- #example ⇒ Object
-
#initialize(name, type, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(name, type, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
6 7 8 9 10 11 |
# File 'lib/restspec/schema/attribute.rb', line 6 def initialize(name, type, = {}) self.name = name self.type = type self.example_override = .fetch(:example, nil) self.allowed_abilities = .fetch(:for, [:checks, :examples]) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/restspec/schema/attribute.rb', line 4 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/restspec/schema/attribute.rb', line 4 def type @type end |
Instance Method Details
#can_be_checked? ⇒ Boolean
21 22 23 |
# File 'lib/restspec/schema/attribute.rb', line 21 def can_be_checked? allowed_abilities.include?(:checks) end |
#can_generate_examples? ⇒ Boolean
17 18 19 |
# File 'lib/restspec/schema/attribute.rb', line 17 def can_generate_examples? allowed_abilities.include?(:examples) end |
#example ⇒ Object
13 14 15 |
# File 'lib/restspec/schema/attribute.rb', line 13 def example @example ||= example_override end |