Class: BinData::SanitizedFields
- Inherits:
-
SanitizedParameter
- Object
- SanitizedParameter
- BinData::SanitizedFields
- Includes:
- Enumerable
- Defined in:
- lib/bindata/sanitize.rb
Overview
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #[](idx) ⇒ Object
- #add_field(type, name, params) ⇒ Object
- #all_field_names_blank? ⇒ Boolean
- #any_field_has_parameter?(parameter) ⇒ Boolean
- #copy_fields(other) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #field_names ⇒ Object
- #has_field_name?(name) ⇒ Boolean
-
#initialize(hints) ⇒ SanitizedFields
constructor
A new instance of SanitizedFields.
- #length ⇒ Object
- #no_field_names_blank? ⇒ Boolean
Constructor Details
#initialize(hints) ⇒ SanitizedFields
Returns a new instance of SanitizedFields.
75 76 77 78 |
# File 'lib/bindata/sanitize.rb', line 75 def initialize(hints) @fields = [] @hints = hints end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
79 80 81 |
# File 'lib/bindata/sanitize.rb', line 79 def fields @fields end |
Instance Method Details
#[](idx) ⇒ Object
87 88 89 |
# File 'lib/bindata/sanitize.rb', line 87 def [](idx) @fields[idx] end |
#add_field(type, name, params) ⇒ Object
81 82 83 84 85 |
# File 'lib/bindata/sanitize.rb', line 81 def add_field(type, name, params) name = nil if name == "" @fields << SanitizedField.new(name, type, params, @hints) end |
#all_field_names_blank? ⇒ Boolean
111 112 113 |
# File 'lib/bindata/sanitize.rb', line 111 def all_field_names_blank? @fields.all? { |f| f.name == nil } end |
#any_field_has_parameter?(parameter) ⇒ Boolean
119 120 121 |
# File 'lib/bindata/sanitize.rb', line 119 def any_field_has_parameter?(parameter) @fields.any? { |f| f.has_parameter?(parameter) } end |
#copy_fields(other) ⇒ Object
123 124 125 |
# File 'lib/bindata/sanitize.rb', line 123 def copy_fields(other) @fields.concat(other.fields) end |
#each(&block) ⇒ Object
99 100 101 |
# File 'lib/bindata/sanitize.rb', line 99 def each(&block) @fields.each(&block) end |
#empty? ⇒ Boolean
91 92 93 |
# File 'lib/bindata/sanitize.rb', line 91 def empty? @fields.empty? end |
#field_names ⇒ Object
103 104 105 |
# File 'lib/bindata/sanitize.rb', line 103 def field_names @fields.collect { |field| field.name_as_sym } end |
#has_field_name?(name) ⇒ Boolean
107 108 109 |
# File 'lib/bindata/sanitize.rb', line 107 def has_field_name?(name) @fields.detect { |f| f.name_as_sym == name.to_sym } end |
#length ⇒ Object
95 96 97 |
# File 'lib/bindata/sanitize.rb', line 95 def length @fields.length end |
#no_field_names_blank? ⇒ Boolean
115 116 117 |
# File 'lib/bindata/sanitize.rb', line 115 def no_field_names_blank? @fields.all? { |f| f.name != nil } end |