class Bluepine::Attributes::Attribute
An abstract Attribute
based class.
@abstract
Attributes
name[R]
Public Class Methods
new(name, options = {})
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 18 def initialize(name, options = {}) @name = name @options = self.class.options.merge(options) end
Public Instance Methods
attributes()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 95 def attributes {} end
default()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 112 def default @options[:default] end
deprecated()
click to toggle source
deprecated attribute should be listed in schema
# File lib/bluepine/attributes/attribute.rb, line 100 def deprecated @options.fetch(:deprecated, false) end
description()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 116 def description @options[:description] end
format()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 83 def format @options[:format] end
if()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 67 def if @options[:if] end
in()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 63 def in @options[:in] end
match()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 51 def match @options[:match] end
method()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 55 def method @options[:method] || @name end
native_type()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 79 def native_type type end
null()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 75 def null @options.fetch(:null, false) end
of()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 59 def of @options[:of] end
options()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 23 def options @options.merge({ name: @name, match: match, method: method, type: type, native_type: native_type, of: of, in: send(:in), if: @options[:if], unless: @options[:unless], null: null, spec: spec, spec_uri: spec_uri, format: format, private: private, deprecated: deprecated, required: required, default: default, description: description, attributes: attributes.values&.map(&:options), }) end
private()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 104 def private @options.fetch(:private, false) end
required()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 108 def required @options.fetch(:required, false) end
serializable?()
click to toggle source
Should not be listed in schema or serialize this attribute
# File lib/bluepine/attributes/attribute.rb, line 121 def serializable? !private end
spec()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 87 def spec nil end
spec_uri()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 91 def spec_uri nil end
type()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 47 def type self.class.name.demodulize.chomp("Attribute").underscore end
unless()
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 71 def unless @options[:unless] end
value(value)
click to toggle source
# File lib/bluepine/attributes/attribute.rb, line 125 def value(value) value.nil? ? default : value end