Class: Ruleby::Steel::WhenInternal
- Inherits:
-
Object
- Object
- Ruleby::Steel::WhenInternal
- Defined in:
- lib/dsl/steel.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #& ⇒ Object
-
#initialize(tag, type) ⇒ WhenInternal
constructor
A new instance of WhenInternal.
- #method_missing(method_id, *args, &block) ⇒ Object
- #to_atoms ⇒ Object
Constructor Details
#initialize(tag, type) ⇒ WhenInternal
Returns a new instance of WhenInternal.
164 165 166 167 168 |
# File 'lib/dsl/steel.rb', line 164 def initialize(tag, type) @tag = tag @type = type @builder = WhenPropertyBuilder.new self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/dsl/steel.rb', line 187 def method_missing(method_id, *args, &block) m = method_id.to_s suffix = m.to_s[-1..-1] if suffix == '=' new_m = m[0,m.size-1] if args[0].class == Array && args[0].size > 1 && args[0][1] == :% wp = @builder.create new_m do |x,y| x == y end wp.references args[0][0] return wp else wp = @builder.create new_m do |x| x == args[0] end return wp end else wp = @builder.create(m, &block) if args.size > 0 && args[0] if block_given? wp.references args[0] else wp.tag = args[0] end end return wp end end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
163 164 165 |
# File 'lib/dsl/steel.rb', line 163 def tag @tag end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
163 164 165 |
# File 'lib/dsl/steel.rb', line 163 def type @type end |
Instance Method Details
#& ⇒ Object
183 184 185 |
# File 'lib/dsl/steel.rb', line 183 def & return self end |
#to_atoms ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/dsl/steel.rb', line 170 def to_atoms atoms = [] = {@tag => :class} @builder.property_hash.each_value do |wp| [wp.tag] = wp.name if wp.tag end @builder.property_keys.each do |key| wp = @builder.property_hash[key] atoms = atoms + [wp.to_atom()] end return atoms end |