Module: Hobix::BaseProperties

Included in:
BaseContent, Weblog
Defined in:
lib/hobix/base.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.append_features(klass) ⇒ Object



286
287
288
289
# File 'lib/hobix/base.rb', line 286

def self.append_features klass
    super
    klass.extend ClassMethods
end

Instance Method Details

#property_mapObject

Build a simple map of properties



264
265
266
267
268
269
270
271
# File 'lib/hobix/base.rb', line 264

def property_map
    self.class.properties.map do |name, opts|
        if opts
            yreq = opts[:req] ? :req : :opt
            ["@#{ name }", yreq] if yreq
        end
    end.compact
end

#to_yaml_propertiesObject

Build a property map for the YAML module



273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/hobix/base.rb', line 273

def to_yaml_properties
    property_map.find_all do |prop, req|
        case req
        when :opt
            not instance_variable_get( prop ).nil?
        when :req
            true
        end
    end.
    collect do |prop, req|
        prop
    end
end