module Bodhi::Properties::ClassMethods

Public Instance Methods

properties() click to toggle source

Retuns a Hash of the Classes properties @return [Hash] The classes properties and options

# File lib/bodhi-slam/properties.rb, line 25
def properties; @properties; end
property(name, options) click to toggle source

Set a new property with the given name and options @param name [String, Symbol] @param options [Hash] @return [nil] @example

Resource.property("age", type: Integer, required: true, min: 18)
Resource.property("birthday", type: DateTime, required: true)
Resource.property(:tags, type: String, multi: true)
Resource.property(:dogs", type: "Dog", multi: true)
# File lib/bodhi-slam/properties.rb, line 40
def property(name, options)
  attr_accessor name.to_sym
  @properties[name.to_sym] = options.reduce({}) do |memo, (k, v)|
    memo.merge({ Bodhi::Support.reverse_camelize(k.to_s).to_sym => v})
  end

  return nil
end
property_names() click to toggle source

A list of all property names @return [Array<String>]

# File lib/bodhi-slam/properties.rb, line 29
def property_names; @properties.keys; end