Class: GatherContent::Config::Element::Text
- Defined in:
- lib/gather_content/config/elements/text.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#limit_type ⇒ Object
Returns the value of attribute limit_type.
-
#plain_text ⇒ Object
Returns the value of attribute plain_text.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Base
#label, #microcopy, #name, #required
Instance Method Summary collapse
-
#initialize(name = "", required = false, label = "", microcopy = "", value = "", limit_type = :chars, limit = 0, plain_text = true) ⇒ Text
constructor
A new instance of Text.
- #serialize(options = nil) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name = "", required = false, label = "", microcopy = "", value = "", limit_type = :chars, limit = 0, plain_text = true) ⇒ Text
9 10 11 12 13 14 15 |
# File 'lib/gather_content/config/elements/text.rb', line 9 def initialize(name = "", required = false, label = "", microcopy = "", value = "", limit_type = :chars, limit = 0, plain_text = true) super(name, required, label, microcopy) @value = value @limit_type = limit_type @limit = limit @plain_text = plain_text end |
Instance Attribute Details
#limit ⇒ Object
Returns the value of attribute limit.
7 8 9 |
# File 'lib/gather_content/config/elements/text.rb', line 7 def limit @limit end |
#limit_type ⇒ Object
Returns the value of attribute limit_type.
7 8 9 |
# File 'lib/gather_content/config/elements/text.rb', line 7 def limit_type @limit_type end |
#plain_text ⇒ Object
Returns the value of attribute plain_text.
7 8 9 |
# File 'lib/gather_content/config/elements/text.rb', line 7 def plain_text @plain_text end |
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/gather_content/config/elements/text.rb', line 7 def value @value end |
Instance Method Details
#serialize(options = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gather_content/config/elements/text.rb', line 17 def serialize( = nil) raise ArgumentError, "limit_type is can only be :words or :chars" unless [ :words, :chars ].include?(limit_type) raise ArgumentError, "limit be a positive number" if limit.to_i < 0 super.merge({ type: 'text', value: value, limit_type: limit_type.to_s, limit: limit.to_i, plain_text: !!plain_text }) end |