Module: Rea::Dsl::Behavioral::ClassMethods

Defined in:
lib/rea/dsl/behavioral.rb

Instance Method Summary collapse

Instance Method Details

#classification(options = {}, &block) ⇒ Object



15
16
17
18
19
20
# File 'lib/rea/dsl/behavioral.rb', line 15

def classification options={}, &block
  include ::Rea::AspectType::Classification
  rea_ast[:classification] = {}
  Rea::CategoryType.find_or_create_by_name name.to_s, options
  block.call if block_given?
end

#description(name, media, options = {}) ⇒ Object



28
29
30
# File 'lib/rea/dsl/behavioral.rb', line 28

def description name, media, options={}
  rea[name] = ::Rea::AspectType::Description.new :name=>name, :media=>media
end

#due_date(name, options = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rea/dsl/behavioral.rb', line 32

def due_date name, options={}
  options = {:name=>name, :activation_rule=>'true'}.merge(options)
  rea[name] = ::Rea::AspectType::DueDateType.new options
  define_method "#{name}_state".to_sym do
    if try(name).nil?
      :disabled
    else
      if send(name) > Time.now
        :incoming
      else
        :expired
      end
    end
  end
end

#identification(name, identifier) ⇒ Object



23
24
25
26
# File 'lib/rea/dsl/behavioral.rb', line 23

def identification name, identifier
  rea_ast[:identifier] = ::Rea::AspectType::IdentifierSetup.new :name=>name, :identifier=>identifier
  self.before_create :create_id_string
end