Module: Hobix::BaseProperties::ClassMethods

Defined in:
lib/hobix/base.rb

Overview

Returns the complete list of properties for the immediate class. If called on an inheriting class, inherited properties are included.

Instance Method Summary collapse

Instance Method Details

#_(name, opts = nil) ⇒ Object

Quick property definitions in class definitions.



251
252
253
254
255
# File 'lib/hobix/base.rb', line 251

def _ name, opts = nil
    @__props ||= YAML::Omap[]
    @__props[name] = opts
    attr_accessor name unless method_defined? "#{ name }="
end

#_!(name, opts = {}) ⇒ Object

Property sections



257
258
259
260
261
# File 'lib/hobix/base.rb', line 257

def _! name, opts = {}
    @__sects ||= YAML::Omap[]
    opts[:__sect] = @__props.last[0] rescue nil
    @__sects[name] = opts
end

#prop_sectionsObject



241
242
243
244
245
246
247
248
249
# File 'lib/hobix/base.rb', line 241

def prop_sections
    if superclass.respond_to? :prop_sections
        s = superclass.prop_sections.dup
        (@__sects || {}).each { |k, v| s[k] = v }
        s
    else
        (@__sects || {})
    end
end

#propertiesObject



232
233
234
235
236
237
238
239
240
# File 'lib/hobix/base.rb', line 232

def properties
    if superclass.respond_to? :properties
        s = superclass.properties.dup
        (@__props || {}).each { |k, v| s[k] = v }
        s
    else
        (@__props || {})
    end
end