Class: Audrey::Object::Custom::Field
- Inherits:
-
Object
- Object
- Audrey::Object::Custom::Field
- Defined in:
- lib/audrey.rb
Overview
Audrey::Object::Custom::Field
Direct Known Subclasses
Instance Attribute Summary collapse
-
#auto ⇒ Object
Returns the value of attribute auto.
-
#clss ⇒ Object
Returns the value of attribute clss.
-
#graph ⇒ Object
Returns the value of attribute graph.
-
#name ⇒ Object
Returns the value of attribute name.
-
#publish ⇒ Object
Returns the value of attribute publish.
-
#read ⇒ Object
Returns the value of attribute read.
-
#required ⇒ Object
Returns the value of attribute required.
-
#write ⇒ Object
Returns the value of attribute write.
Instance Method Summary collapse
-
#add_to_class(tgt) ⇒ Object
————————————————————————— add_to_class.
-
#auto_add(object) ⇒ Object
————————————————————————— auto_add.
-
#base_checks(*opts) ⇒ Object
————————————————————————— base_checks.
-
#has_checks? ⇒ Boolean
————————————————————————— has_checks?.
-
#initialize(p_name) ⇒ Field
constructor
————————————————————————— initialize.
-
#normalize(val) ⇒ Object
————————————————————————— normalize.
Constructor Details
#initialize(p_name) ⇒ Field
initialize
2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 |
# File 'lib/audrey.rb', line 2064 def initialize(p_name) @name = p_name @read = true @write = true @clss = nil @auto = false @publish = false @graph = false # normalize name @name = @name.strip @name = @name.gsub(/\s+/mu, ' ') end |
Instance Attribute Details
#auto ⇒ Object
Returns the value of attribute auto.
2056 2057 2058 |
# File 'lib/audrey.rb', line 2056 def auto @auto end |
#clss ⇒ Object
Returns the value of attribute clss.
2055 2056 2057 |
# File 'lib/audrey.rb', line 2055 def clss @clss end |
#graph ⇒ Object
Returns the value of attribute graph.
2058 2059 2060 |
# File 'lib/audrey.rb', line 2058 def graph @graph end |
#name ⇒ Object
Returns the value of attribute name.
2052 2053 2054 |
# File 'lib/audrey.rb', line 2052 def name @name end |
#publish ⇒ Object
Returns the value of attribute publish.
2057 2058 2059 |
# File 'lib/audrey.rb', line 2057 def publish @publish end |
#read ⇒ Object
Returns the value of attribute read.
2053 2054 2055 |
# File 'lib/audrey.rb', line 2053 def read @read end |
#required ⇒ Object
Returns the value of attribute required.
2059 2060 2061 |
# File 'lib/audrey.rb', line 2059 def required @required end |
#write ⇒ Object
Returns the value of attribute write.
2054 2055 2056 |
# File 'lib/audrey.rb', line 2054 def write @write end |
Instance Method Details
#add_to_class(tgt) ⇒ Object
add_to_class
2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 |
# File 'lib/audrey.rb', line 2085 def add_to_class(tgt) # $tm.hrm # Ruby doesn't like it if we use an @ variable in the method definition # of another class. nme = @name.dup # read if @read tgt.define_method(nme) do return @node[nme] end end # write if @write # reference self inside the method for assigning the instance # variable me = self # definew method tgt.define_method("#{nme}=") do |val| val = me.normalize(val) return @node[nme] = val end end end |
#auto_add(object) ⇒ Object
auto_add
2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 |
# File 'lib/audrey.rb', line 2120 def auto_add(object) # early exit @auto or return # get audrey node node = object.audrey # init new_val = nil # add to node if Audrey::Object::Custom.descendant?(@auto) new_val = @auto.new('accessor'=>node.db) elsif @auto.is_a?(Proc) new_val = @auto.call(object) end # set new value node[@name] = new_val end |
#base_checks(*opts) ⇒ Object
base_checks
2170 2171 |
# File 'lib/audrey.rb', line 2170 def base_checks(*opts) end |
#has_checks? ⇒ Boolean
has_checks?
2159 2160 2161 |
# File 'lib/audrey.rb', line 2159 def has_checks? return false end |
#normalize(val) ⇒ Object
normalize
2148 2149 2150 |
# File 'lib/audrey.rb', line 2148 def normalize(val) return val end |