Class: BinData::SanitizedFields
- Inherits:
-
SanitizedParameter
- Object
- SanitizedParameter
- BinData::SanitizedFields
- Includes:
- Enumerable
- Defined in:
- lib/bindata/sanitize.rb
Overview
Instance Method Summary collapse
- #[](idx) ⇒ Object
- #add_field(type, name, params) ⇒ Object
- #all_field_names_blank? ⇒ Boolean
- #any_field_has_parameter?(parameter) ⇒ Boolean
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #field_name?(name) ⇒ Boolean
- #field_names ⇒ Object
-
#initialize(hints, base_fields = nil) ⇒ SanitizedFields
constructor
A new instance of SanitizedFields.
- #length ⇒ Object
- #no_field_names_blank? ⇒ Boolean
- #raw_fields ⇒ Object
Constructor Details
#initialize(hints, base_fields = nil) ⇒ SanitizedFields
Returns a new instance of SanitizedFields.
71 72 73 74 |
# File 'lib/bindata/sanitize.rb', line 71 def initialize(hints, base_fields = nil) @hints = hints @fields = base_fields ? base_fields.raw_fields : [] end |
Instance Method Details
#[](idx) ⇒ Object
86 87 88 |
# File 'lib/bindata/sanitize.rb', line 86 def [](idx) @fields[idx] end |
#add_field(type, name, params) ⇒ Object
76 77 78 79 80 |
# File 'lib/bindata/sanitize.rb', line 76 def add_field(type, name, params) name = nil if name == "" @fields << SanitizedField.new(name, type, params, @hints) end |
#all_field_names_blank? ⇒ Boolean
110 111 112 |
# File 'lib/bindata/sanitize.rb', line 110 def all_field_names_blank? @fields.all? { |f| f.name.nil? } end |
#any_field_has_parameter?(parameter) ⇒ Boolean
118 119 120 |
# File 'lib/bindata/sanitize.rb', line 118 def any_field_has_parameter?(parameter) @fields.any? { |f| f.has_parameter?(parameter) } end |
#each(&block) ⇒ Object
98 99 100 |
# File 'lib/bindata/sanitize.rb', line 98 def each(&block) @fields.each(&block) end |
#empty? ⇒ Boolean
90 91 92 |
# File 'lib/bindata/sanitize.rb', line 90 def empty? @fields.empty? end |
#field_name?(name) ⇒ Boolean
106 107 108 |
# File 'lib/bindata/sanitize.rb', line 106 def field_name?(name) @fields.detect { |f| f.name_as_sym == name.to_sym } end |
#field_names ⇒ Object
102 103 104 |
# File 'lib/bindata/sanitize.rb', line 102 def field_names @fields.collect(&:name_as_sym) end |
#length ⇒ Object
94 95 96 |
# File 'lib/bindata/sanitize.rb', line 94 def length @fields.length end |
#no_field_names_blank? ⇒ Boolean
114 115 116 |
# File 'lib/bindata/sanitize.rb', line 114 def no_field_names_blank? @fields.all? { |f| f.name != nil } end |
#raw_fields ⇒ Object
82 83 84 |
# File 'lib/bindata/sanitize.rb', line 82 def raw_fields @fields.dup end |