Class: Brujula::Scheme
- Inherits:
-
Object
- Object
- Brujula::Scheme
- Defined in:
- lib/brujula/scheme.rb
Instance Attribute Summary collapse
-
#allow_any ⇒ Object
(also: #allow_any?)
readonly
Returns the value of attribute allow_any.
-
#default_type ⇒ Object
readonly
Returns the value of attribute default_type.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
-
#typed ⇒ Object
(also: #typed?)
readonly
Returns the value of attribute typed.
Instance Method Summary collapse
-
#initialize(klass, options = {}, block = nil) ⇒ Scheme
constructor
A new instance of Scheme.
- #key_collection ⇒ Object
-
#typed_keys(type) ⇒ Object
TODO.
- #validate_data!(data) ⇒ Object
Constructor Details
#initialize(klass, options = {}, block = nil) ⇒ Scheme
Returns a new instance of Scheme.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/brujula/scheme.rb', line 8 def initialize(klass, = {}, block = nil) @klass = klass = @keys = {} @typed = !![:typed] @default_type = [:default_type] || :string @allow_any = !![:allow_any] if [:as] block = Brujula::Raml::V1_0.const_get( Inflecto.camelize([:as]) ).block end instance_exec(&block) end |
Instance Attribute Details
#allow_any ⇒ Object (readonly) Also known as: allow_any?
Returns the value of attribute allow_any.
3 4 5 |
# File 'lib/brujula/scheme.rb', line 3 def allow_any @allow_any end |
#default_type ⇒ Object (readonly)
Returns the value of attribute default_type.
3 4 5 |
# File 'lib/brujula/scheme.rb', line 3 def default_type @default_type end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
3 4 5 |
# File 'lib/brujula/scheme.rb', line 3 def keys @keys end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
3 4 5 |
# File 'lib/brujula/scheme.rb', line 3 def reference @reference end |
#typed ⇒ Object (readonly) Also known as: typed?
Returns the value of attribute typed.
3 4 5 |
# File 'lib/brujula/scheme.rb', line 3 def typed @typed end |
Instance Method Details
#key_collection ⇒ Object
25 26 27 |
# File 'lib/brujula/scheme.rb', line 25 def key_collection @keys.values end |
#typed_keys(type) ⇒ Object
TODO
33 34 35 36 37 |
# File 'lib/brujula/scheme.rb', line 33 def typed_keys(type) # TODO keys.values.select do |brujula_key| brujula_key.valid_for_type?(type) end end |
#validate_data!(data) ⇒ Object
29 30 31 |
# File 'lib/brujula/scheme.rb', line 29 def validate_data!(data) valid_keys?(data) || raise(Brujula::Raml::RequiredProperty) # && enough_data?(data)) end |