Class: ReleaseHighlights::Validator::Entry
- Inherits:
-
Object
- Object
- ReleaseHighlights::Validator::Entry
- Includes:
- ActiveModel::Validations, ActiveModel::Validations::Callbacks
- Defined in:
- lib/release_highlights/validator/entry.rb
Constant Summary collapse
- AVAILABLE_IN =
%w[Free Premium Ultimate].freeze
- HYPHENATED_ATTRIBUTES =
[:self_managed, :gitlab_com].freeze
Instance Attribute Summary collapse
-
#available_in ⇒ Object
Returns the value of attribute available_in.
-
#description ⇒ Object
Returns the value of attribute description.
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#gitlab_com ⇒ Object
Returns the value of attribute gitlab_com.
-
#image_url ⇒ Object
Returns the value of attribute image_url.
-
#name ⇒ Object
Returns the value of attribute name.
-
#published_at ⇒ Object
Returns the value of attribute published_at.
-
#release ⇒ Object
Returns the value of attribute release.
-
#self_managed ⇒ Object
Returns the value of attribute self_managed.
-
#stage ⇒ Object
Returns the value of attribute stage.
Instance Method Summary collapse
-
#initialize(entry) ⇒ Entry
constructor
A new instance of Entry.
- #read_attribute_for_validation(key) ⇒ Object
- #validate_available_in ⇒ Object
- #validate_published_at ⇒ Object
Constructor Details
#initialize(entry) ⇒ Entry
Returns a new instance of Entry.
25 26 27 |
# File 'lib/release_highlights/validator/entry.rb', line 25 def initialize(entry) @entry = entry end |
Instance Attribute Details
#available_in ⇒ Object
Returns the value of attribute available_in.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def available_in @available_in end |
#description ⇒ Object
Returns the value of attribute description.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def description @description end |
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
11 12 13 |
# File 'lib/release_highlights/validator/entry.rb', line 11 def entry @entry end |
#gitlab_com ⇒ Object
Returns the value of attribute gitlab_com.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def gitlab_com @gitlab_com end |
#image_url ⇒ Object
Returns the value of attribute image_url.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def image_url @image_url end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def name @name end |
#published_at ⇒ Object
Returns the value of attribute published_at.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def published_at @published_at end |
#release ⇒ Object
Returns the value of attribute release.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def release @release end |
#self_managed ⇒ Object
Returns the value of attribute self_managed.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def self_managed @self_managed end |
#stage ⇒ Object
Returns the value of attribute stage.
12 13 14 |
# File 'lib/release_highlights/validator/entry.rb', line 12 def stage @stage end |
Instance Method Details
#read_attribute_for_validation(key) ⇒ Object
45 46 47 |
# File 'lib/release_highlights/validator/entry.rb', line 45 def read_attribute_for_validation(key) value_for(key) end |
#validate_available_in ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/release_highlights/validator/entry.rb', line 37 def validate_available_in available_in = value_for('available_in') if !available_in.is_a?(Array) || available_in.empty? || available_in.any? { |p| AVAILABLE_IN.exclude?(p) } errors.add(:available_in, "must be one of #{AVAILABLE_IN}") end end |
#validate_published_at ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/release_highlights/validator/entry.rb', line 29 def validate_published_at published_at = value_for('published_at') return if published_at.is_a?(Date) errors.add(:published_at, 'must be valid Date') end |