Class: SixSaferpay::Generators::Attribute
- Inherits:
-
Object
- Object
- SixSaferpay::Generators::Attribute
- Defined in:
- lib/generators/models.rb
Instance Attribute Summary collapse
-
#mandatory ⇒ Object
Returns the value of attribute mandatory.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #boolean? ⇒ Boolean
-
#initialize(name, type, mandatory = false) ⇒ Attribute
constructor
A new instance of Attribute.
- #mandatory? ⇒ Boolean
- #string? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, type, mandatory = false) ⇒ Attribute
Returns a new instance of Attribute.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/generators/models.rb', line 61 def initialize(name, type, mandatory = false) @name = name @type = type if mandatory == "true" @mandatory = true elsif mandatory == "false" @mandatory = false else @mandatory = mandatory end end |
Instance Attribute Details
#mandatory ⇒ Object
Returns the value of attribute mandatory.
59 60 61 |
# File 'lib/generators/models.rb', line 59 def mandatory @mandatory end |
#name ⇒ Object
Returns the value of attribute name.
59 60 61 |
# File 'lib/generators/models.rb', line 59 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
59 60 61 |
# File 'lib/generators/models.rb', line 59 def type @type end |
Instance Method Details
#boolean? ⇒ Boolean
81 82 83 |
# File 'lib/generators/models.rb', line 81 def boolean? @type.downcase == "boolean" end |
#mandatory? ⇒ Boolean
73 74 75 |
# File 'lib/generators/models.rb', line 73 def mandatory? @mandatory end |
#string? ⇒ Boolean
77 78 79 |
# File 'lib/generators/models.rb', line 77 def string? @type.downcase == "string" end |
#to_h ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/generators/models.rb', line 89 def to_h hash = Hash.new hash.merge!(name: name) hash.merge!(type: type) hash.merge!(mandatory: mandatory) hash end |
#to_s ⇒ Object
85 86 87 |
# File 'lib/generators/models.rb', line 85 def to_s to_h end |