Class: Activecube::Field
- Inherits:
- 
      Object
      
        - Object
- Activecube::Field
 
- Defined in:
- lib/activecube/field.rb
Instance Attribute Summary collapse
- 
  
    
      #definition  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute definition. 
- 
  
    
      #name  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute name. 
Class Method Summary collapse
Instance Method Summary collapse
- #expression(_model, _arel_table, _slice, _cube_query) ⇒ Object
- 
  
    
      #initialize(name, arg = nil)  ⇒ Field 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Field. 
Constructor Details
#initialize(name, arg = nil) ⇒ Field
Returns a new instance of Field.
| 18 19 20 21 | # File 'lib/activecube/field.rb', line 18 def initialize name, arg = nil @name = name @definition = arg end | 
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
| 4 5 6 | # File 'lib/activecube/field.rb', line 4 def definition @definition end | 
#name ⇒ Object (readonly)
Returns the value of attribute name.
| 4 5 6 | # File 'lib/activecube/field.rb', line 4 def name @name end | 
Class Method Details
.build(name, arg) ⇒ Object
| 6 7 8 9 10 11 12 13 14 15 16 | # File 'lib/activecube/field.rb', line 6 def self.build name, arg if arg.kind_of? String Field.new name, arg elsif arg.kind_of? Hash Field.new name, arg.symbolize_keys elsif arg.kind_of?(Class) && arg < Field arg.new name else raise Activecube::InputArgumentError, "Unexpected field #{name} definition with #{arg.class.name}" end end | 
Instance Method Details
#expression(_model, _arel_table, _slice, _cube_query) ⇒ Object
| 23 24 25 26 | # File 'lib/activecube/field.rb', line 23 def expression _model, _arel_table, _slice, _cube_query raise Activecube::InputArgumentError, "String expression expected for #{name} field, instead #{definition.class.name} is found" unless definition.kind_of?(String) definition end |