Class: Extface::Mapping
- Inherits:
-
Object
- Object
- Extface::Mapping
- Defined in:
- lib/extface/mapping.rb
Instance Attribute Summary collapse
-
#i_extra_module ⇒ Object
readonly
Returns the value of attribute i_extra_module.
-
#i_find_key ⇒ Object
readonly
Returns the value of attribute i_find_key.
-
#i_klass ⇒ Object
readonly
Returns the value of attribute i_klass.
-
#i_param ⇒ Object
readonly
Returns the value of attribute i_param.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(resource, options) ⇒ Mapping
constructor
A new instance of Mapping.
- #mount_point ⇒ Object
Constructor Details
#initialize(resource, options) ⇒ Mapping
Returns a new instance of Mapping.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/extface/mapping.rb', line 4 def initialize(resource, ) @name = ([:as] || resource).to_s @i_klass = ([:interfaceable_type] || name.to_s.classify).to_s.constantize @i_param = [:interfaceable_param] || "#{name}_id" #default #{resource}_id # key to find interfaceable in controller, when # :uuid then find_by! :uuid => params[:uuid] # :shop_uuid then find_by! :uuid => params[:shop_uuid] # :shop_id then find_by! :id => params[:shop_id] @i_find_key = @i_param[/^(#{resource}_|)(\w+)/,2] # FIXME not before schema load #raise "#{@i_klass.name} has no method #{@i_find_key}" unless @i_klass.new.respond_to? @i_find_key #raise "Did you forget to add 'has_extface_devices' in #{@i_klass.name} ?" unless @i_klass.new.respond_to? :extface_devices @i_extra_module = [:controller_include].to_s.constantize if [:controller_include].present? end |
Instance Attribute Details
#i_extra_module ⇒ Object (readonly)
Returns the value of attribute i_extra_module.
3 4 5 |
# File 'lib/extface/mapping.rb', line 3 def i_extra_module @i_extra_module end |
#i_find_key ⇒ Object (readonly)
Returns the value of attribute i_find_key.
3 4 5 |
# File 'lib/extface/mapping.rb', line 3 def i_find_key @i_find_key end |
#i_klass ⇒ Object (readonly)
Returns the value of attribute i_klass.
3 4 5 |
# File 'lib/extface/mapping.rb', line 3 def i_klass @i_klass end |
#i_param ⇒ Object (readonly)
Returns the value of attribute i_param.
3 4 5 |
# File 'lib/extface/mapping.rb', line 3 def i_param @i_param end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/extface/mapping.rb', line 3 def name @name end |
Class Method Details
.find(fullpath) ⇒ Object
27 28 29 |
# File 'lib/extface/mapping.rb', line 27 def find(fullpath) Extface.mappings[fullpath[%r{/(\w+)_extface\/}, 1]] end |
Instance Method Details
#mount_point ⇒ Object
22 23 24 |
# File 'lib/extface/mapping.rb', line 22 def mount_point "#{name}_extface" end |