Class: Compel::Builder::Schema
- Inherits:
-
Object
- Object
- Compel::Builder::Schema
- Includes:
- Common
- Defined in:
- lib/compel/builder/schema.rb
Direct Known Subclasses
Any, Array, Boolean, Date, DateTime, Float, Hash, Integer, JSON, String, Time
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #build_option(name, value, extra_options = {}) ⇒ Object
- #default_options ⇒ Object
- #default_value ⇒ Object
-
#initialize(type) ⇒ Schema
constructor
A new instance of Schema.
- #required? ⇒ Boolean
- #validate(object) ⇒ Object
Methods included from Common
#coerce_if_proc, #default, #if, #is, #length, #max_length, #min_length, #required
Constructor Details
#initialize(type) ⇒ Schema
Returns a new instance of Schema.
15 16 17 18 |
# File 'lib/compel/builder/schema.rb', line 15 def initialize(type) @type = type @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/compel/builder/schema.rb', line 8 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/compel/builder/schema.rb', line 8 def type @type end |
Class Method Details
.human_name ⇒ Object
11 12 13 |
# File 'lib/compel/builder/schema.rb', line 11 def self.human_name "#{self.name.split('::')[1..-1].join('::')}" end |
Instance Method Details
#build_option(name, value, extra_options = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/compel/builder/schema.rb', line 32 def build_option(name, value, = {}) [name] = { value: value }.merge() self end |
#default_options ⇒ Object
38 39 40 |
# File 'lib/compel/builder/schema.rb', line 38 def { required: { value: false } } end |
#default_value ⇒ Object
24 25 26 |
# File 'lib/compel/builder/schema.rb', line 24 def default_value [:default][:value] if [:default] end |
#required? ⇒ Boolean
20 21 22 |
# File 'lib/compel/builder/schema.rb', line 20 def required? [:required][:value] end |