Class: Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Inherits:
-
Object
- Object
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
show all
- Defined in:
- lib/compass/configuration/inheritance.rb
Instance Method Summary
(collapse)
Constructor Details
- (ArrayProxy) initialize(data, attr)
A new instance of ArrayProxy
65
66
67
|
# File 'lib/compass/configuration/inheritance.rb', line 65
def initialize(data, attr)
@data, @attr = data, attr
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(m, *args, &block)
102
103
104
105
106
107
108
109
|
# File 'lib/compass/configuration/inheritance.rb', line 102
def method_missing(m, *args, &block)
a = to_ary
if a.respond_to?(m)
a.send(m,*args, &block)
else
super
end
end
|
Instance Method Details
- (Object) <<(v)
74
75
76
|
# File 'lib/compass/configuration/inheritance.rb', line 74
def <<(v)
@data.send(:add_to_#{@attr}", v)
end
|
- (Object) >>(v)
77
78
79
|
# File 'lib/compass/configuration/inheritance.rb', line 77
def >>(v)
@data.send(:remove_from_#{@attr}", v)
end
|
- (Object) serialize_to_config(prop)
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/compass/configuration/inheritance.rb', line 80
def serialize_to_config(prop)
if v = @data.raw(prop)
"#{prop} = #{v.inspect}"
else
s = ""
if added = @data.instance_variable_get("@added_to_#{@attr}")
added.each do |a|
s << "#{prop} << #{a.inspect}\n"
end
end
if removed = @data.instance_variable_get("@removed_from_#{@attr}")
removed.each do |r|
s << "#{prop} >> #{r.inspect}\n"
end
end
if s[-1..-1] == "\n"
s[0..-2]
else
s
end
end
end
|
- (Object) to_a
71
72
73
|
# File 'lib/compass/configuration/inheritance.rb', line 71
def to_a
to_ary
end
|
- (Object) to_ary
68
69
70
|
# File 'lib/compass/configuration/inheritance.rb', line 68
def to_ary
@data.send(:read_inherited_#{@attr}_array")
end
|