Class: Depo::DijitConventions

Inherits:
Object
  • Object
show all
Defined in:
lib/depo/dijit_conventions.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dijit_full_name) ⇒ DijitConventions

Returns a new instance of DijitConventions.



14
15
16
17
# File 'lib/depo/dijit_conventions.rb', line 14

def initialize(dijit_full_name)
  @dijit_full_name= dijit_full_name
  from_full_name(dijit_full_name)
end

Class Attribute Details

.propsObject (readonly)

Returns the value of attribute props.



5
6
7
# File 'lib/depo/dijit_conventions.rb', line 5

def props
  @props
end

Instance Attribute Details

#cmpObject (readonly)

Returns the value of attribute cmp.



13
14
15
# File 'lib/depo/dijit_conventions.rb', line 13

def cmp
  @cmp
end

Class Method Details

.prop(key, &block) ⇒ Object



6
7
8
9
10
# File 'lib/depo/dijit_conventions.rb', line 6

def prop(key,&block)
  @props||=[]
  @props<< key
  define_method key,&block
end

Instance Method Details

#from_full_name(dijit_full_name) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/depo/dijit_conventions.rb', line 19

def from_full_name(dijit_full_name)
  parts = @dijit_full_name.split('.')
  cmps ={:base_module=>parts[0],:class_name=>parts[-1]}
  if parts.length > 2
    cmps[:modules] = parts[1..-2]
  end
  cmps[:dijit_full_name]=dijit_full_name
  @cmp_hash=cmps
  @cmp = OpenStruct.new(cmps)
end

#from_src(*args) ⇒ Object



54
55
56
# File 'lib/depo/dijit_conventions.rb', line 54

def from_src(*args)
  File.join(*args.flatten.unshift(Depo.config.src_path))
end

#j(*args) ⇒ Object



58
59
60
# File 'lib/depo/dijit_conventions.rb', line 58

def j(*args)
  File.join(*args)
end

#to_hashObject



103
104
105
106
107
# File 'lib/depo/dijit_conventions.rb', line 103

def to_hash
  self.class.props.inject({}) do |hash,prp|
    hash[prp] = send(prp); hash;
  end
end