Sha256: b57a9850d0d328bda96e02b7167fa2d02b6dbcd70538295e011c3e850c10eae0
Contents?: true
Size: 957 Bytes
Versions: 1
Compression:
Stored size: 957 Bytes
Contents
module Cockpit def self.included(base) base.extend(ClassMethods) base.send(:include, InstanceMethods) end module ClassMethods def cockpit(options = {}, &block) if block_given? options = {:store => options.to_sym} unless options.is_a?(Hash) @cockpit = Cockpit::Settings.define!(options.merge(:for => self), &block) @cockpit.roots.map(&:key).flatten.each do |key| define_method key do send(:cockpit).send(key) end define_method "#{key}?" do send(:cockpit).present?(key) end end end @cockpit end unless respond_to?(:key) def key(*args) end end end module InstanceMethods def cockpit(key = nil) @cockpit ||= Cockpit::Settings.new(:record => self) if key @cockpit.definition(key) else @cockpit end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cockpit-0.2.1 | lib/cockpit/core/include.rb |