Class: Filament::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/filament/platform.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



68
69
70
# File 'lib/filament/platform.rb', line 68

def name
  @name
end

Class Method Details

.create(name, attributes) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/filament/platform.rb', line 47

def self.create(name, attributes)
  name = name.to_sym

  prototypes = attributes.delete(:inherit) || []
  prototypes = prototypes.to_a

  platform = new(name, prototypes, attributes)
  @@platforms ||= {}
  @@platforms[name] = platform
end

.find(h) ⇒ Object



58
59
60
61
62
63
# File 'lib/filament/platform.rb', line 58

def self.find(h)
  name = h[:name].to_sym
  
  @@platforms ||= {}
  return @@platforms[name]
end

.import(data) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/filament/platform.rb', line 34

def self.import(data)
  platforms = YAML.load(data)

  platforms.each do |name, map|
    attributes = {}
    map.each do |key, value|
      attributes[key.to_sym] = value
    end
    
    create(name, attributes)
  end
end

.property(*attrs) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/filament/platform.rb', line 7

def self.property(*attrs)
  attrs.each do |a|
    attr_writer(a)
    define_method(a) do
      value = @attributes[a]
      return value unless value.nil?
      prototypes.each do |p| 
        value = p.send(a)
        break if value.nil?
      end
      return value
    end
  end
end

.property_list(*attrs) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/filament/platform.rb', line 22

def self.property_list(*attrs)
  attrs.each do |a|
    attr_writer(a)
    define_method(a) do
      value = @attributes[a] || []
      value = value.to_a
      prototypes.each {|p| value += p.send(a)}
      return value
    end
  end
end

Instance Method Details

#classpathObject



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/filament/platform.rb', line 74

def classpath
  base_classpath = @attributes[:classpath]

  classpath = []
  classpath += base_classpath unless base_classpath.nil?

  tags.each do |tag|
    tag_classpath = TAGS[tag]
    classpath += tag_classpath unless tag_classpath.nil?
  end

  return classpath
end

#prototypesObject



70
71
72
# File 'lib/filament/platform.rb', line 70

def prototypes
  return @prototypes.collect {|p| Platform.find(:name => p)}
end